Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see the full server response for this API error message in Google Scripts?

I'm getting an error response from the API that I'm using, but Google scripts seems to truncate the message. How can I see the full message in Google scripts?

This is the message:

Request failed for https://api.myintervals.com/task/ returned code 400. Truncated server response: {"personid":"180761","status":"Bad Request","code":400,"error":{"code":18,"message":"Validation error has occurred (missing required field/paramet... (use muteHttpExceptions option to examine full response) (line 171, file "IntervalsPull")

like image 455
Takeshi Patterson Avatar asked Aug 19 '16 10:08

Takeshi Patterson


1 Answers

Just as @DrSatan1 pointed in the comment, pass muteHttpExceptions option in the parameter to suppress the exception and get the error returned as HTTPResponse.

options = {muteHttpExceptions: true};
var response = UrlFetchApp.fetch("https://api.myintervals.com/task/", options);
Logger.log(response.getContentText()); 

Now view your logs to see the complete error response.

like image 119
m5khan Avatar answered Oct 25 '22 12:10

m5khan