GlideHTTPResponse - Global
-
- UpdatedJan 30, 2025
- 7 minutes to read
- Yokohama
- API reference
The GlideHTTPResponse API provides utility methods to perform common functions with Glide HTTP responses.
GlideHTTPResponse - getAllHeaders()
Returns a list of all headers.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Array | List of all the headers associated with the endpoint call. |
Example
This example shows how to delete a specified incident from the Incident table using the del() method.
Output
GlideHTTPResponse - getBody()
Returns a string containing the body for the HTTP response.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | HTTP response body. |
Example
This example shows how to use the getBody() method to display the contents of the return results of an endpoint call.
Output
GlideHTTPResponse - getCookies()
Returns the list of cookies associated with an endpoint call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Array | List containing the name and value of each cookie as a string. |
Example
This example shows how to use the getCookies() method to display the cookies associated with a endpoint response.
Output
GlideHTTPResponse - getErrorCode()
Returns the current error code returned by an endpoint.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Integer | The error code. 0 is returned if there are no errors. |
Example
This example shows how to view the error code of the last error message thrown by the instance for the associated REST call using the getErrorCode() method.
Output
GlideHTTPResponse - getErrorMessage()
Returns the last error encountered.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Text string that describes the last error encountered. |
Example
This example shows how to view the last error message thrown by the instance for the associated REST call using the getErrorMessage() method.
Output
GlideHTTPResponse - getHeader(String name)
Returns the header specified in the passed-in parameter.
Name | Type | Description |
---|---|---|
name | String | Name of the response header to return, such as Content-Type. |
Type | Description |
---|---|
String | Value of the specified header for the current response. |
Example
This example shows how to display the contents of the Content-Type header.
Output
GlideHTTPResponse - getHeaders()
Returns all headers associated with the endpoint response.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | Object containing all associated headers. |
Example
This example shows how to display all of the headers associated with an endpoint call using the getHeaders() method.
Output
GlideHTTPResponse - getHttpMethod()
Returns the HTTP method associated with the specified endpoint call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | HTTP method associated with the endpoint call, such as
org.apache.commons.httpclient.methods.GetMethod@f83e63 .
Format: org.apache.commons.httpclient.methods.<Method> |
Example
This example shows how to display the HTTP method used when calling the associated endpoint using the getMethod() method.
Output
GlideHTTPResponse - getStatusCode()
Returns the last status code for an endpoint call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
int | HTTP response status code. |
Example
This example shows how to get the status code of a REST call after it executes using the getStatusCode() method.
Output:
GlideHTTPResponse - haveError()
Returns a flag that indicates whether there were any errors while processing the endpoint call.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Boolean | Flag that indicates whether there were any errors when processing the endpoint
call. Valid values: Returns true if an error has occurred, or false if there are no
errors
|
Example
This example shows how no error is flagged when the sys_id for an incident is valid using the haveError() method.
Output
Example
This example shows how an error is flagged when the sys_id for an incident is not valid (not found) using the haveError() method.
Output
On this page
- GlideHTTPResponse - getAllHeaders()
- GlideHTTPResponse - getBody()
- GlideHTTPResponse - getCookies()
- GlideHTTPResponse - getErrorCode()
- GlideHTTPResponse - getErrorMessage()
- GlideHTTPResponse - getHeader(String name)
- GlideHTTPResponse - getHeaders()
- GlideHTTPResponse - getHttpMethod()
- GlideHTTPResponse - getStatusCode()
- GlideHTTPResponse - haveError()