RestResponse¶
Represents the response of a REST request.
Remarks¶
Read the status with RestResponse.StatusCode and the body with RestResponse.Content, or convert the body with RestResponse.ToJson, RestResponse.ToXml or RestResponse.ToBase64. A response returned by RestRequest.Execute is not checked; call RestResponse.Verify to throw an error for an unexpected status.
Examples¶
Handle a missing resource¶
1 2 3 4 5 6 7 8 9 10 11 | |
Capabilities¶
Response Metadata¶
- RestResponse.Content: Gets the response content as text.
- RestResponse.ContentType: Gets the content type of the response.
- RestResponse.StatusCode: Gets the name of the HTTP status code of the response, such as
OK,CreatedorNotFound. - RestResponse.StatusCodeDescription: Gets the HTTP status description returned by the remote server.
Response Validation¶
- RestResponse.GetHeader: Returns the value of a specified header.
- RestResponse.Verify: Verifies the status code of the response and returns the current instance.
Response Conversion¶
- RestResponse.ToBase64: Returns the raw response bytes encoded as Base64.
- RestResponse.ToJson: Returns the response content parsed as JSON.
- RestResponse.ToXml: Returns the response content parsed as an Xml node.