Appgyver Rest Post API application/x-www-form-urlencoded doesn't work

Integrating Rest POST API of content-type : application/x-www/form-url-encoded and tried to integrate through Data rest api and HTTP Request of appgyver, but not able find how to map/send the form data and the request is always sent as json which is failing for the API.

1. Data Rest API Integration

Appgyver Data Rest post api is set up as “application/x-www-form-url-encoded”

Request body has been set and its in json format.
image

Networks tab shows the payload request is in json and remote server doesn’t accept this request body.

See the below SS which sends the request with FormData which is correct and working in desktop version

2. HTTP Request
Tried to make the POST API calling through Appgyver HTTP request and content-type is set as form-urlencoded and request body is sent in json format.

We have tried above two ways but not able to find to how to map formData. please guide us to setup formData for application/x-www-form-urlencoded.

Thanks
Kishore

Hi! For the latter, you are passing a text as response body – you should instead use a formula to pass it as an Object. I think HTTP Request is the only working way to do this, as discussed here and here.

Thanks, Mevi for the response!

Please confirm whether we can use the below formula to encode form-data object of URL encoded content type.

(ENCODE_OBJECT_FOR_URL)

suggest us how the proper types can be passed to form the object

Hello Mevi,

I have made POST API call through HTTP Request and request body has been set to the below formula.

Formula: ENCODE_OBJECT_FOR_URL({mobile_client:appVars.client_id,grant_type:"*****",client_secret:appVars.client_secret,username:pageVars.credentials.username,password:pageVars.credentials.password})

In the networks tab we could see the payload request is sent as below.

0=m&1=o&2=b&3=i&4=l&5=e&6=_&7=c&8=l&9=i&…

Instead of as :: mobile_client=m****&grant_type=****&…**

Please suggest the formula to make the payload request to be sent as above

Thanks
Kishore.

Oh no, don’t use the ENCODE_OBJECT_FOR_URL! Just go with

{mobile_client:appVars.client_id,grant_type:"*****",client_secret:appVars.client_secret,username:pageVars.credentials.username,password:pageVars.credentials.password}

For my own understanding, since I’ve never fully understood how this works, the request body is entered as JSON even when the type is set to x-www-form-urlencoded ? Im assuming the JSON request body gets converted to form-urlencoded format?

I’m not sure either, but yes I think so :sweat_smile:

I met the same issue even if I didn’t use function ENCODE_OBJECT_FOR_URL. Would you please kindly take a look at my post

Thanks