I am struggling with the SendInBlue API I am introducing in my application, which returns some information solely based on the HTTP status code.
I don’t understand why, but when the body of the response is empty, the HTTP/s block result seems to be null. I would have thought it returns an object with a status code and a body or an error message. Is that not the case ?
The only thing I found in the documentation on the block in the Codeless documentation is “optionally returns the server response”. Can you clarify the “optionally” and advise how to know if it’s a 404, a 200 or the such ?
Now, for some reason, the logger within the async block never fires. If I remove the async block, then it does fire, but it returns an empty content. This is probably correct since the SendInBlue API specifies an empty body, with status code 204 (Update a contact).
But something seems fishy with the return value of the HTTP/s block :
as discussed above, the question remains of how I can get that status code 204 (or 400 or 404 when it fails) ?
and what in this value could cause the logger block not to fire, even though the API call does ?
If you need further detail, the logic is available in the Users beforeUpdate event handler of my app D7075715-5086-625A-FFAB-39C2F40FB200.
NB : I added the async block because I don’t want the API call to delay the user update further, and it should run in a parallel thread anyways.
Code in the “Run code async” block will run after your “try… catch…” block. And when code from “Run code async” block will run and “https” block will throw error here nothing to catch it.
In your code no sense to add “run async code” block in “try catch” block.
Add “try catch block” to “async” block
Hmm, thanks for the reply.
I am not trying to get the error’s status code but rather the HTTPS response status code. So there normally isn’t any error. Or did I miss something ?
Got your point. I will see if I can get it to work that way.
Although in some cases I believe their API does make the difference only through HTTP status codes. For example Create a contact : the difference between created and updated is only between 201 and 204 status code.
But I will probably find a way. If not, I will come back to this thread.
Ohhh, it makes sense. I was thinking you were asking about our API response codes. Please take a look at this support topic, it describes how to get to the lower-level details for an HTTPS request using code: