HTTPResponse
Contains the methods for getting the response's payload and status code.
Example usage:
function main() {
var response = UrlFetchApp.fetch('http://microsoft.com');
Logger.log('status code: ' + response.getResponseCode() + '\n' +
'payload as a string: ' + response.getContentText());
}
Method Name | Return Type | Description |
---|---|---|
getContent() | byte[] | Gets the response's payload as a byte array. |
getContentText() | string | Gets the response's payload as a string. |
getResponseCode() | integer | Gets the response's HTTP status code. |
Gets the response's payload as a byte array.
Type | Description |
---|---|
byte[] | The response's payload as a byte array. |
Gets the response's payload as a string.
Type | Description |
---|---|
string | The response's payload as a string. If the payload is a JSON object, use JSON.parse(response.getContentText()) to get the object. |
Gets the response's HTTP status code.
Type | Description |
---|---|
integer | The response's HTTP status code, which indicates the request's success or failure. For example, 200 if the GET request succeeded. |