I'm consuming a REST API that only accepts x-www-form-urlencoded.

I'm trying to request an object:






I understand: number=500&month=12&year=20; the API also requires 'id'.

How would the 'id' be included?




You might not need to send an id field at all, but if the API specifies that this is required, this StackOverflow describes how to correctly nest form parameters:


Thank you. I tried but did not work.  OutSystems converted to 'text/plain'.

I also tried %5b/%5d; referenced in StackOverflow, this was also converted to 'text/plain'.

I confirmed, API requires the id field; the API will take different id fields for example id, accessid, tokenid, etc. and provide a response.

Any additional thoughts?

That sounds like an incorrect Content-Type in your API call.

Try adding a Content-Type Request Header as an input to your REST call, and set its value to the required type to avoid sending plaintext.


I added the content-type.

When running a test in API window; it works fine, but when running in web emulator and OutSystems Now I get an error (400 bad request).

In checking the API service; the 'card' has dropped from the post body. 




That's very strange, but probably not related to your API implementation anymore.

Run the code through the built-in debugger and make you're passing all required inputs to the API call.

APIs are always invoked server-side (IIS, Wildfly, or other) so calling it from the web emulator and OutSystems Now shouldn't make a difference here.

Fixed it. Thank you for the help.

When using Content-Type input parameter; few things I did.

  • Location of the input parameter should match the location in post body. (Content-type was first under API Action)
  • Request format should be plain text.
  • Plain text has only 1 input parameter of text.
  • Using an Assign, Built the 'id' outside the API using the structure you mentioned above.
  • I don't believe the structure can be built with the API as there's only 1 input.   

I didn't realize the above.

Thank you again for the help and coaching! Much Appreciated!



Great to hear!

A little late, but just discovered this guide as well: https://www.outsystems.com/forums/discussion/36156/guide-consume-rest-api-with-form-url-encoded-request/ 

Leaving it here for future reference.