Reputation: 1415
I am trying to obtain the status message of the response to a POST to a rest service via:
var response = UrlFetchApp.fetch(<url>, <params>);
I need the status description as reported by the server which does not appear to be available as part of the HTTPResponse object returned by the fetch method.
I can get the status code using:
response.getResponseCode();
But no luck on the message associated with it. I have wrapped the fetch call in a try/catch block, but the error message returned using that method is an error message provided by the spreadsheet service, not the original, raw status description from the server response.
Any ideas on how to obtain this piece of information, most appreciated.
Upvotes: 1
Views: 2402
Reputation: 12673
The associated message from the service should be available in HTTPResponse.getContentText()
. You'll need to pass the optional parameter muteHttpExceptions
set to true
in the UrlFetchApp.fetch()
request to prevent an exception from being thrown.
Upvotes: 1