Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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());
}
Methods
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. |
getContent
Gets the response's payload as a byte array.
Returns
Type | Description |
---|---|
byte[] | The response's payload as a byte array. |
getContentText
Gets the response's payload as a string.
Returns
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. |
getResponseCode
Gets the response's HTTP status code.
Returns
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. |