Sample code for 30+ languages & platforms
JavaScript

Send a REST Request with No Body

See more REST Examples

Demonstrates Rest.FullRequestNoBody, which sends a complete request with no request body (such as a GET or DELETE) and returns the response body as text.

Background. This is the simplest full-request convenience method, ideal for retrieval and deletion calls that carry no request payload.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

var rest = new CkRest();
var bTls = true;
var bAutoReconnect = true;
success = rest.Connect("example.com",443,bTls,bAutoReconnect);
if (success == false) {
    console.log(rest.LastErrorText);
    return;
}

//  Send a complete request with no request body, such as a GET or DELETE.  The response body is read
//  as text and returned.
var responseText = rest.FullRequestNoBody("GET","/api/items/123");
if (rest.LastMethodSuccess == false) {
    console.log(rest.LastErrorText);
    return;
}

console.log(responseText);