Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > REST API Connections > RestConnection class > RestConnection Methods

doRequest

Scroll Prev Next More

 

Runs HTTP request. Unlike requestWithAuth, no authorization data is added to the request.

Syntax

 

doRequest( request )

 

Arguments

 

request - HttpRequest object.

Return value

 

Returns array if the operation was successful or false otherwise.

The returned array has the following elements:

 

responseCode

integer. HTTP response code. Values 200-299 are success codes.

content

string. Response body received from server as is.

header

string. Response header as received from server.

Example

 

When false is returned use lastError() function to get the error message.

 

dynamic rconn = null, request = null, result = null;
rconn = CommonFunctions.getRESTConn();
request = new HttpRequest( "https://api.service.com/resource" );
result = rconn.doRequest(request);
if (!result) {
  MVCFunctions.Echo("Error occurred. Description: ");
    MVCFunctions.Echo(rconn.lastError());
} else {
  MVCFunctions.Echo("Request successful. Result: ");
  MVCFunctions.Echo(result["content"]);
}