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: 140
Austria

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"?
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: 140
Austria

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".
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: 140
Austria

Was thanked: 18 time(s) in 18 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!
mario  
#8 Posted : Sunday, March 17, 2024 6:52:40 PM(UTC)
mario

Rank: Newbie

Groups: Registered
Joined: 3/17/2024(UTC)
Posts: 6
Italy
Location: Terni

Sorry everyone
I am new on this forum
I use filemaker, and I need to make a small application to get data from Filemaker Server with API REST
Inside filemaker script I setup CURL option variable like this:

-X POST
D $_response_headers
--header "Content-Type: application/json"
--header "Authorization: Basic cmVzdDpyZXN0" (this is the username and password "base 64 encoded")
-d @$_authentication_json (This is the variable that get Json result, in the case of altova I use $MT_HTTPExecute_Result variable

I use the RESTful API Request panel, use Basic/OAuth setup, where I write username and password
But I get error:

Error response:
{"messages":[{"message":"Invalid content type (application/x-www-form-urlencoded). These are valid: application/json","code":"1708"}],"response":{}}
Error executing REST POST request: FatalError: I/O operation on file 'https://cmstudio.eu/fmi/data/vLatest/databases/beezwax_data_api_demo_19/sessions' failed.
Details:
I/O Error 400: Bad Request

I don't know where to write the curl option and how to write in the parametr table inside RESTful API Request panel
mario  
#9 Posted : Sunday, March 17, 2024 6:56:50 PM(UTC)
mario

Rank: Newbie

Groups: Registered
Joined: 3/17/2024(UTC)
Posts: 6
Italy
Location: Terni

If some good soul like to try with is personale MobileTogether, just make a botton and istruction and try to get result from my server
The urls is:
https://cmstudio.eu/fmi/...ata_api_demo_19/sessions
User rest
Password rest

cURL options are:
-X POST
-D $_response_headers
--header "Content-Type: application/json"
--header "Authorization: Basic cmVzdDpyZXN0"
-d @$_authentication_json (This is variable where I store Json result inside Filemaker)

How I can translate this VS Altova MobileTogether Designe ?

ELP  
#10 Posted : Monday, March 18, 2024 9:09:04 AM(UTC)
ELP

Rank: Newbie

Groups: Registered
Joined: 10/7/2021(UTC)
Posts: 8
Austria

Was thanked: 1 time(s) in 1 post(s)
Hi Mario!

It should be possible to achieve this with an "Execute REST Request" action. Please see the attached screenshot how to map your parameters. Since I don't know the JSON required by your server the request ends in an error. I hope the attached solution helps.
File Attachment(s):
Execute REST Request.mtd (2kb) downloaded 4 time(s).
data.json (1kb) downloaded 6 time(s).
ELP attached the following image(s):
Execute REST Request.png
mario  
#11 Posted : Monday, March 18, 2024 10:44:43 AM(UTC)
mario

Rank: Newbie

Groups: Registered
Joined: 3/17/2024(UTC)
Posts: 6
Italy
Location: Terni

I will check in the afternon, thanks alot
mario  
#12 Posted : Monday, March 18, 2024 7:28:12 PM(UTC)
mario

Rank: Newbie

Groups: Registered
Joined: 3/17/2024(UTC)
Posts: 6
Italy
Location: Terni

Thanks ELP
I change my way, I use Odata
No error, but also with your sample no error
I have a stupid question (I am 70 yeas old.... you understand..)
No error on the request result, I store the result on $MT_HTTPExecute_Result
But when I try to uodate node from $MT_HTTPExecute_Result give me error

This is the error
Starting Project Validation (C:\Users\mario\Documents\Altova\VenturiLocal\Odata.mtd) ...
Project Validation (C:\Users\mario\Documents\Altova\VenturiLocal\Odata.mtd) - 0 error(s), 0 warning(s)
Starting Simulation ...
Executed on server: Next page: MainPage
Executed on server: Load '$XML1' (Url: )
Execution Time: 0.00s
Data transferred from server to client: New page XML '$XML1'
Executed on server: Control Action of Button Button1:
Executing REST GET request
URL: https://cmstudio.eu/fmi/...OData_SampleData/PERSON?$select=ID,FirstName,LastName
Execution Time: 0.07s
Cannot Update Node '$PERSISTENT/Root/$XML1/JsonResult/Result' (no 'Target Node' found)
Simulation - 0 error(s), 1 warning(s)
mario  
#13 Posted : Monday, March 18, 2024 7:29:28 PM(UTC)
mario

Rank: Newbie

Groups: Registered
Joined: 3/17/2024(UTC)
Posts: 6
Italy
Location: Terni

Attacched my new file
File Attachment(s):
Odata.mtd (2kb) downloaded 3 time(s).
ELP  
#14 Posted : Tuesday, March 19, 2024 9:10:35 AM(UTC)
ELP

Rank: Newbie

Groups: Registered
Joined: 10/7/2021(UTC)
Posts: 8
Austria

Was thanked: 1 time(s) in 1 post(s)
Hi Mario!

I've modified your solution a little bit so you get your JSON result linked under the result element. Please note that the current solution will always link the result of the new request as last child under result. You might want to remove the previous results with the Delete Node(s) action first.
File Attachment(s):
Odata.mtd (2kb) downloaded 5 time(s).
ELP attached the following image(s):
json-result.png
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.