Do authenticated request and return parsed JSON
Syntax
requestJson( resource, method, payload, headers, urlParams)
Arguments
resource
string. Resource address within API. resource is added to the REST API Connection URL.
For example, when REST API Connection URL is https://service.com/api
and resource is /orders, the resulting URL where request will be sent is https://service.com/ap/orders
method
string. The HTTP method. In most cases it should be GET or POST. More rarely used methods are PUT, DELETE, HEAD. Consult your API manual for more info.
payload (optional)
array. Associative array of parameters passed in the request body. payload should only be used with POST or PUT methods. See also HttpRequest class
headers (optional)
array. Associative array of HTTP headers to be sent to the server. See also HttpRequest class
Return value
Returns array representing parsed JSON response when request was successful.
Returns false otherwise. Use lastError() function to get the error details. If the server returns an error, lastError() returns the whole server response, header and the body.
Example