How to get only the status of a put request

Hi,


I am quite new on developing with OutSystems and also working with APIs, so my question could look very stupid, but I didn't find an answer for it. So far, I managed to build what I needed very well, even though I'm not sure if I'm following all good practices, but (almost) all is working good so far. However, now I need to do something which is probably simple, but that I'm unable to do it. 

I'm sending a put request within a Server Action. The triggered action is completed successfully as I could check in the destination. The only thing I need is to know whether the response was 200 (success) or not. But when I test the API in the Studio, the response is much more "complete". It brings a response structure that I won't use. Also, when it's successfully, the structure is one, but when the response is 422, for instance, the response's structure is different.


After running the put request, I'd like to have an If component where it'd take one action if it was successful (response 200) and other if it's not. 


Additional note: this is a code I'm trying to convert. In Python, I stored in a variable the response from this put request and got no JSON response but only a line "<Response 200>" for example.


If you need any further information in order to understand this question, please let me know.

Solution

Hi Felipe,

Can you check this post to see if it helps you.

Please note that is for Version 10, but you can also find the same for version 11. 

This one explains how to handle REST errors in 11.


Update info you can also check this blog post.

Solution

Hi Felipe,

How do you "send the PUT request"? Are you using an Action from the HTTPHandler, or are you calling a REST service? Because of the latter, if the response is anything but 200, you'll get an Exception and all results are lost, unless youuse the OnAfterRequest to change the error code to 200.

Nuno Rolo wrote:

Hi Felipe,

Can you check this post to see if it helps you.

Please note that is for Version 10, but you can also find the same for version 11. 

This one explains how to handle REST errors in 11.


Update info you can also check this blog post.

 Hi Nuno,


Thank you very much for your reply.


I'm already reading all the info and I do believe, it'll solve my problem. If so, I'll get back here and mark your response as a solution, otherwise, I'll post my remaining questions.


Thanks again.


Stay safe,


Felipe