Support Forum

Ask questions and get help from MobileTogether experts.
MobileTogether Product Information
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Roel  
#1 Posted : Sunday, November 19, 2017 11:18:55 PM(UTC)
Roel

Rank: Newbie

Groups: Registered
Joined: 11/19/2017(UTC)
Posts: 4
Netherlands

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):
BtnLogin.gif
AFC  
#2 Posted : Monday, November 20, 2017 9:39:57 AM(UTC)
AFC

Rank: Administration

Groups: Registered, Administrators
Joined: 9/15/2014(UTC)
Posts: 34
Austria

Was thanked: 5 time(s) in 5 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"?
Roel  
#3 Posted : Monday, November 20, 2017 10:48:26 AM(UTC)
Roel

Rank: Newbie

Groups: Registered
Joined: 11/19/2017(UTC)
Posts: 4
Netherlands

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):
HTTP200_also_not_logging.gif
AFC  
#4 Posted : Monday, November 20, 2017 12:44:13 PM(UTC)
AFC

Rank: Administration

Groups: Registered, Administrators
Joined: 9/15/2014(UTC)
Posts: 34
Austria

Was thanked: 5 time(s) in 5 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".
Roel  
#5 Posted : Monday, November 20, 2017 1:10:04 PM(UTC)
Roel

Rank: Newbie

Groups: Registered
Joined: 11/19/2017(UTC)
Posts: 4
Netherlands

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?
AFC  
#6 Posted : Monday, November 20, 2017 2:07:05 PM(UTC)
AFC

Rank: Administration

Groups: Registered, Administrators
Joined: 9/15/2014(UTC)
Posts: 34
Austria

Was thanked: 5 time(s) in 5 post(s)
Hi Roel!

Return codes >= 299 are handled as error.
thanks 1 user thanked AFC for this useful post.
Roel on 11/20/2017(UTC)
Roel  
#7 Posted : Monday, November 20, 2017 2:17:16 PM(UTC)
Roel

Rank: Newbie

Groups: Registered
Joined: 11/19/2017(UTC)
Posts: 4
Netherlands

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!
Users browsing this topic
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.