PostJson
- Last UpdatedSep 07, 2018
- 1 minute read
This method calls the POST api which expects post data in JSON format.
Method 1:
IExtensionsWebAPI.PostJson(EndPoint, PostData, Handler)
Parameters
-
EndPoint: Web Api End point of Get request
-
PostData: Data to be posted as string in JSON fromat
-
Handler: Handler Method of Lua script to handle the response JSON data.
Method 2:
IExtensionsWebAPI.PostJson(EndPoint, PostData, Handler, HeaderCollection)
Parameters
-
EndPoint: Web Api End point of Get request
-
PostData: Data to be posted as string in JSON fromat
-
Handler: Handler Method of Lua script to handle the response JSON data.
-
HeaderCollection: Header collection in form of Table
Example
local postdata = '{"name": "paul rudd", "movies": ["I Love You Man", "Role Models"]}'
local returnvalue = "something"
function Calculate(params)
local headerCollection = {}
headerCollection["ZUMO-API-VERSION"] = "2.0.0"
local response = IExtensionsWebAPI.PostJson("https://www.example.com/api/users", postdata, "Handle", headerCollection)
return returnvalue
end
function Handle(result)
returnvalue = result["data"]["name"]
end