Skip to content
Advertisement

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”)

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement