MobileTogether Support Forum
»
Designer
»
MobileTogether Designer
»
REST 400 response body of POST not in $MT_HTTPExecute_Result
Rank: Newbie
Groups: Registered
Joined: 11/19/2017(UTC) Posts: 4  Thanks: 1 times
|
Have an REST call with POST which returns HTTP 400 but with json body. Want to store the json in a persistent variable so I can use the json to determine what the next action is for the user. Issue: the $MT_HTTPExecute_Result variable is empty.. while if I do the same call in other tools like SOAP UI it gives clean json response. Screenshot of settings made below, even tried ith with "Continue" in the "Execute REST Request" and use the failed part to log it but it simply does not log the response.. Can you see what I am doing wrong? Roel attached the following image(s):
|
|
|
|
Rank: Administration
Groups: Registered, Administrators Joined: 9/15/2014(UTC) Posts: 133  Was thanked: 18 time(s) in 18 post(s)
|
Hi Roel!
In case of HTTP errors (and 400 is an error), we currently do not set $MT_HTTPExecute_Result. Why does your server return "bad request"?
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/19/2017(UTC) Posts: 4  Thanks: 1 times
|
Thanks AFC, The application gives back 400 response because it cannot handle the request due to missing data. The response then indicates which fields it still needs additional info on. Example for this one: The REST endpoint is used to get a user token for a multi-customer saas application. So the user submits userid and password and expects to get token back. If the user and password combination exist for more then 1 customer the REST response gives back the 400 response and list of customers that exists. So the user can resubmit the request with userid, password and customer. Note: Even when I get a HTTP 200 response the json payload that contains the token is not registered in $MT_HTTPExecute_Result. See attached example where the succesfull flow would also log that but it is not Roel attached the following image(s):
|
|
|
|
Rank: Administration
Groups: Registered, Administrators Joined: 9/15/2014(UTC) Posts: 133  Was thanked: 18 time(s) in 18 post(s)
|
Hi Roel!
In case you want to get the result as a string value, you will have to serialize it, i.e. "serialize( $MT_HTTPExecute_Result )". If you want to access distinct elements, you can use e.g. "$MT_HTTPExecute_Result/json/element1".
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/19/2017(UTC) Posts: 4  Thanks: 1 times
|
Thanks AFC,
serialize indeed works for the HTTP 200.Thank you for that! Unfortunately the 400 reponse was indeed not captured. Would be nice to have this in future. Can you indicate which HTTP response codes will be stored in $MT_HTTPExecute_Result so I can think if interim solution for the REST api itself?
|
|
|
|
Rank: Administration
Groups: Registered, Administrators Joined: 9/15/2014(UTC) Posts: 133  Was thanked: 18 time(s) in 18 post(s)
|
Hi Roel!
Return codes >= 299 are handled as error.
|
 1 user thanked AFC for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/19/2017(UTC) Posts: 4  Thanks: 1 times
|
Thanks AFC,
If also the error response will ever get logged I would be all for it :)! For now this clarifies my original question.
thanks!
|
|
|
|
MobileTogether Support Forum
»
Designer
»
MobileTogether Designer
»
REST 400 response body of POST not in $MT_HTTPExecute_Result
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.