REST.delete: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Created page with "{{MacroFunction |name=REST.delete |trusted=true |version=1.5 |description= Perform an HTTP delete request to the specified URL to delete the specified resource. |usage= <sour...")
 
No edit summary
Line 13: Line 13:


'''Parameters'''
'''Parameters'''
{{param|url|}}
{{param|url|String containing the URL to the resource or collection of resources.}}
{{param|headers|}}
{{param|headers|JSON object containing header key:value pairs.}}
{{param|getFullResponse|Boolean (0:1) to get full response.}}
{{param|getFullResponse|Boolean (0:1). True(1) to get full response.}}
'''Returns'''
'''Returns'''


HTTP response as JSON (if full response) or server response, usually JSON but can be XML, HTML, or other formats.
HTTP response as JSON (if full response) or server response, usually JSON but can be XML, HTML, or other formats.
'''Note:''' The delete request returns an empty string if the full response is not requested.


|example=
|example=
Line 32: Line 34:
Returns:
Returns:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
TEXT HERE
Full Response: {
  "status": 204,
  "headers":  {
    "access-control-allow-origin": ["*"],
    "cf-ray": ["4b928693e9805414-LAX"],
    "date": ["Sun, 17 Mar 2019 22:50:25 GMT"],
    "etag": ["W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\""],
    "expect-ct": ["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],
    "server": ["cloudflare"],
    "set-cookie": ["__cfduid=dc5a1bd174f8f46cb9721f3a3338cff631552863025; expires=Mon, 16-Mar-20 22:50:25 GMT; path=/; domain=.reqres.in; HttpOnly"],
    "x-powered-by": ["Express"]
  }
}
</source>
</source>



Revision as of 22:52, 17 March 2019

REST.delete() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.5
Perform an HTTP delete request to the specified URL to delete the specified resource.

Usage

REST.delete(url, getFullResponse)
REST.delete(url, headers, getFullResponse)

Parameters

  • url - String containing the URL to the resource or collection of resources.
  • headers - JSON object containing header key:value pairs.
  • getFullResponse - Boolean (0:1). True(1) to get full response.

Returns

HTTP response as JSON (if full response) or server response, usually JSON but can be XML, HTML, or other formats.

Note: The delete request returns an empty string if the full response is not requested.

Example

Delete the indicated resource.
[h: baseURL = "https://reqres.in"]
[h: path = "/api/users/2"]

[r: response = REST.delete(baseURL + path, 1)]
<br><br>
[r: response = REST.delete(baseURL + path, 0)]

Returns:

Full Response: {
  "status": 204,
  "headers":   {
    "access-control-allow-origin": ["*"],
    "cf-ray": ["4b928693e9805414-LAX"],
    "date": ["Sun, 17 Mar 2019 22:50:25 GMT"],
    "etag": ["W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\""],
    "expect-ct": ["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],
    "server": ["cloudflare"],
    "set-cookie": ["__cfduid=dc5a1bd174f8f46cb9721f3a3338cff631552863025; expires=Mon, 16-Mar-20 22:50:25 GMT; path=/; domain=.reqres.in; HttpOnly"],
    "x-powered-by": ["Express"]
  }
}

See Also

Version Changes

  • 1.5 - Added to main MapTool build.