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.

 

$rconn = getRESTConn();
$request = new HttpRequest( "https://api.service.com/resource" );
$response = $rconn->doRequest( $request );
if( $response === false ) {
echo "Error occurred. Description: " . $rconn->lastError();
} else {
echo "Request successful. Response body: " . $response["content"];
}

 

 

 

 

 

 

 

 

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software