question

psilvestre avatar image
psilvestre asked

Is there any way to get whole http.result object through Cloud Script server API using http.request?

Hi,

I want to get http result returned using http.request (with pre-defined http object) in Cloud Script, because I need to check http Status code.

It only returns result.responseContent but not the whole object (with httpStatusCode that is the parameter that I need). It is returned to client if logRequestAndResponse is put to true, but I need it in Cloud Script...

is it possible to get it?

Thanks

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The wrapped http.request in Cloud Script only returns the body of the response, as you've seen (though you can log the full response by setting the logRequestAndResponse parameter to true: http.request(url, httpMethod, content, contentType, headers, true);). Granted, that doesn't help if what you want to do is use the httpStatusCode in your Cloud Script logic.

If this is something you'd like to see us add to the Cloud Script functionality, I'd recommend adding it to our Feature Requests forum, so that others can see and vote on this (votes help us with prioritization).

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

psilvestre avatar image psilvestre commented ·

Ok thanks, I will do that.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.