REST.put: Difference between revisions

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


|also=
|also=
[[RESTful Function|RESTful Function]]
[[RESTful Functions Overview|RESTful Functions Overview]]


|changes=
|changes=

Revision as of 04:09, 16 March 2019

REST.put() Function

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

Introduced in version 1.5
Perform an HTTP put request to the specified URL to update an existing resource.

Usage

REST.put(url, payload, mediaType, getFullResponse)
REST.put(url, payload, mediaType, headers, getFullResponse)

Parameters

  • url -
  • payload -
  • mediaType -
  • headers -
  • getFullResponse - Boolean (0: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.

Example

Update a user with a put request.
[h: baseURL = "https://reqres.in"]
[h: path = "/api/users/2"]
[h: mediaType = "application/json; charset=utf-8"]
[h: getFullResponse = 0]

[h: payload = '{ "name": "morpheus", "job": "zion resident" }']

[h: response = REST.put(baseURL + path, payload, mediaType, getFullResponse)]

<br>
<pre>
[r: json.indent(response, 2)]
</pre>

Returns:

TEXT HERE

See Also

Version Changes

  • 1.5 - Added to main MapTool build.