HttpPut(url, data, [headers]) Last updated: 12. Feb 2024

Calls specified web service with method PUT. Expects JSON. Parses JSON to object.

Parameters

Name Type Description
url string URL to call with HTTP PUT.
data object Data to PUT
headers (optional) object Name / value object that will be converted to HTTP headers.

Returns

Returns JSON parsed object.

Example

Data

{
"login" : "test",
"password": "test"
}

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
// Basic authentication
let headers = {
    "Authorization" : "BASIC " + docly.base64(login + ":" + password)
};

let data = {
    "Field1" : "123"
};
 
// Call some API
var result = docly.httpPut("https://somewebsite.com/API/Call?id=1", JSON.stringify(data), headers);
 
// Handle error 
if(result.DoclyError) docly.assert(result.DoclyError);
 
// Output result
return JSON.stringify(result);

Output

The #JS code above produces the output shown below:
Only works in API functions, no demo.