aqHttpStatusCode Object

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

aqHttpStatusCode is a helper object containing the values of HTTP status codes defined as properties. You can use these in a bundle with the aqHttp, aqHttpRequest, and aqHttpResponse objects – for example, to compare status codes you get and values you expect.

Properties

The aqHttpStatusCode object contains the properties listed in the table below.

These status codes identify the most common statuses, and may be not used by your server.
Name Value
(Status Code)
Description
Continue 100 The Continue status indicates the server has received the request headers and the client should send the request body.
SwitchingProtocols 101 The Switching Protocols status indicates the requester has asked the server to switch protocols and the server has agreed to do that.
OK 200 The OK status indicates the request has been sent successfully, and the server has provided all the necessary information.
Created 201 The Created status indicates the request has been fulfilled, and the new resource appeared on the server.
Accepted 202 The Accepted status indicates the request has been taken for processing, but the processing has not been completed.
NonAuthoritativeInformation 203 The Non-Authoritative Information status indicates the server is a proxy and providing the modified information from the origin server.
NoContent 204 The No Content status indicates the server has successfully processed the request but has not provided any content.
ResetContent 205 The Reset Content status indicates the server has successfully processed the request, but is not returning any content.
PartialContent 206 The Partial Content status indicates the server is delivering only a part of the resource in accordance with a range header that the client has sent.
MultipleChoices 300 The Multiple Choices status indicates there are multiple options for the resource from which the client can choose.
MovedPermanently 301 The Moved Permanently status indicates this and all future request should be directed to the given URI.
Found 302 The Found status indicates the request should be redirected to another location. The server sends the new location in the location header.
SeeOther 303 The See Other status indicates the response to the request can be found under another URI using a GET method.
NotModified 304 The Not Modified status indicates the resource has not been modified since the version specified by the request headers If-Modified-Since or If-Non-Match.
UseProxy 305 The Use Proxy status indicates the requested resource is available only through a proxy, and the service has provided the proxy address in the response.
Unused 306 Unused belongs to the Switch Proxy status, which is no longer used, but originally required subsequent requests to use the specified proxy.
TemporaryRedirect 307 The Temporary Redirect status indicates the current request should be repeated with another URI, but future requests should use the original URI.
BadRequest 400 The Bad Request status indicates the request could not be understood by the server. The server sends that status when no other error is applicable, or if the exact error is unknown or does not have its own error code.
Unauthorized 401 The Unauthorized status is similar to 403, but it comes in place when the server requires Basic authentication (that is, credentials must be provided in the Authorization header), and the request has failed or do not provided it.
PaymentRequired 402 The Payment Required status is reserved for the future use.
Forbidden 403 The Forbidden status indicates the request was valid, but the server will not run the requested operation – for example, if a user does not have the necessary permissions.
NotFound 404 The Not Found status indicates that requested resource is not found but can become available in the future.
MethodNotAllowed 405 The Method Not Allowed indicates a request method is not supported for the requested resource – for example, PUT on a read-only resource.
NotAcceptable 406 The Not Acceptable status indicates the requested resource can generate only an unacceptable content as defined by the Accept header provided with the request.
ProxyAuthenticationRequired 407 The Proxy Authentication Required status indicates the client must first authenticate itself with the proxy.
RequestTimeout 408 The Request Timeout status indicates the server has timed out while waiting for the request.
Conflict 409 The Conflict status indicates the request could not be processed because of conflict in that request.
Gone 410 The Gone status indicates the requested resource is no longer available and will not be available again.
LengthRequired 411 The Length Required status indicates the request did not specify the length of its content despite it is required by the server.
PreconditionFailed 412 The Precondition Failed status indicates the server does not meet one of the conditions the client has provided in the request.
RequestEntityTooLarge 413 The Payload Too Large status indicates the request is larger than the server is able or willing to process.
RequestUriTooLong 414 The URI Too Long status indicates the URI the client has provided is too long for the server to process – for example, too much encoded data appearing in the query string of the GET request.
UnsupportedMediaType 415 The Unsupported Media Type status indicates the request includes an entity of a media type which the server or resource does not support.
RequestedRangeNotSatisfiable 416 The Range Not Satisfiable status indicates the client has asked for only a specific part of the file, but the server cannot afford this – for example, if that specific part lies beyond the file’s end.
ExpectationFailed 417 The Expectation Failed status indicates the server cannot meet the requirements of the Expect header of the request.
InternalServerError 500 The Internal Server Error status is a generic error message indicating an unexpected event has occurred and no more specific information can be provided.
NotImplemented 501 The Not Implemented status indicates the server either has not recognized the request method, or it cannot fulfill the request.
BadGateway 502 The Bad Gateway status indicates an intermediate proxy server received a bad response from another proxy or the origin server.
ServiceUnavailable 503 The Service Unavailable status indicates the server is currently unavailable (because it is overloaded or down for maintenance).
GatewayTimeout 504 The Gateway Timeout status indicates the server was acting as a proxy or gateway and did not receive a response from the target server at the needed time.
HttpVersionNotSupported 505 The HTTP Version Not Supported status indicates the server does not support the HTTP protocol used in the request.

Example

JavaScript, JScript

function httpRequestCode()
{
  var address = "http://petstore.swagger.io/v2/store/inventory";
  
  var okStatus = aqHttpStatusCode.OK;
  
  var aqHttpRequest = aqHttp.CreateGetRequest(address);
  
  var aqHttpResponse = aqHttpRequest.Send();
  
  if (aqHttpResponse.StatusCode == okStatus)
  {
    Log.Message("Everything is OK.");
  }
  else
  {
    Log.Message("Something unexpected happened. Check the response status code.");
  }
}

Python

def httpRequestCode():
  address = "http://petstore.swagger.io/v2/store/inventory"
  
  okStatus = aqHttpStatusCode.OK
  
  aqHttpRequest = aqHttp.CreateGetRequest(address)
  
  aqHttpResponse = aqHttpRequest.Send()
  
  if aqHttpResponse.StatusCode == okStatus:
    Log.Message("Everything is OK.")
  else:
    Log.Message("Something went wrong. Check the response status code.")

VBScript

Sub httpRequestCode
  Dim address, okStatus, aqHttpRequest, aqHttpResponse
  
  address = "http://petstore.swagger.io/v2/store/inventory"
  
  okStatus = aqHttpStatusCode.OK
  
  Set aqHttpRequest = aqHttp.CreateGetRequest(address)
  Set aqHttpResponse = aqHttpRequest.Send()
  
  If aqHttpResponse.StatusCode = okStatus Then
    Log.Message("Everything is OK.")
  Else
    Log.Message("Something unexpected happened. Check the response status code.")
  End If
End Sub

DelphiScript

function httpRequestCode;
var address, okStatus, aqHttpRequest, aqHttpResponse;
begin 

  address := 'http://petstore.swagger.io/v2/store/inventory';
  
  okStatus := aqHttpStatusCode.OK;
  
  aqHttpRequest := aqHttp.CreateGetRequest(address);
  
  aqHttpResponse := aqHttpRequest.Send();
  
  if aqHttpResponse.StatusCode = okStatus then
    Log.Message('Everything is OK.')
  else 
    Log.Message('Something unexpected happened. Check the response status code.');

end;

C++Script, C#Script

function httpRequestCode()
{
  var address = "http://petstore.swagger.io/v2/store/inventory";
  
  var okStatus = aqHttpStatusCode["OK"];
  
  var aqHttpRequest = aqHttp["CreateGetRequest"](address);
  
  var aqHttpResponse = aqHttpRequest["Send"]();
  
  if (aqHttpResponse["StatusCode"] == okStatus)
  {
    Log["Message"]("Everything is OK.");
  }
  else
  {
    Log["Message"]("Something unexpected happened. Check the response status code.");
  }
}

See Also

aqHttp Object
aqHttpRequest Object
aqHttpResponse Object

Highlight search results