Consume REST: what to put in request?

0
We need to call a REST api where the following is supposed to work: curl --location --request POST "https://some-target-url.com" --header "Content-Type: x-www-form-url-encoded" --data="email=myemail@domain.com" Now, in the call REST activity in my microflow, what do I put in the ‘Request’ part? I tried: email=myemail@domain.com email=”myemail@domain.com” email=”myemail%40domain.com” --data=”email=myemail@domain.com” All failing miserably with response 422. What am I doing wrong? Edit: turns out it needs to be application/x-www-form-url-encoded instead of x-www-form-url-encoded. Why this results in a 422 is beyond me. Other than that, the request formatted as email=myemail@domain.com works. I appreciate the feedback and also accepted Nils' answer. The receiving party said that encoding wasn't necessary, but while @ is no problem, the endpoint threw an error when the email address contained a +.
asked
2 answers
0

With content type “x-www-form-url-encoded” as the name indicates both the keys and values are URL encoded. So with curl you would actually get something like this.

curl --location --request POST "https://some-target-url.com" --header "Content-Type: x-www-form-url-encoded" --data="email=myemail%40domain.com"

In mendix you could use a ‘post’ REST action as described in this forum post below. Just make sure you don’t forget to URL encode the keys and values before adding it to the request body.
https://forum.mendix.com/link/questions/89477
 

answered
0

The error code is:

422 Unprocessable Entity

The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.

For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.

 

Could it be something so simple that you really tried to supply myemail@domain.com instead or your own mail adres?
Otherwise check the other side why your mail address is not accepted.

Regards,

Ronald

 

answered