You are here: Web Services > Consuming Web Services > Reading the Response > Checking if your request completes successfully

Checking if your request completes successfully

A response from the server doesn't guarantee that your request was executed successfully. Many times, the request you submitted contains invalid information (e.g. invalid address, invalid employee ID), which results in the server rejecting to execute your request.

Most web services would use the HTTP status code to indicate whether it manages to execute the request successfully.

You generally get a 200 status code when everything is OK. When something is wrong, you either get a 4xx or 5xx status code. In addition to the HTTP status code, most web services would also have their own error code included in the message body that indicates the type of error, and an error message.

Use the IsSuccessHttpStatusCode property (of the Response object) to check whether the return HTTP status code from the server indicates a successful execution (200).

Define_Com Class(#XPRIM_HttpRequest) Name(#Request)

...

#OK := #Request.Response.IsSuccessHttpStatusCode

#StatusCode := #Request.Response.HttpStatusCode

Next: Reading the Response Body