API post method with parameters into body

Hello
In order to make an API login process (and get back into my app the token…) I have to consume an API request with the POST method. The problem is that the documentation says to use a body object to send user and password parameters ( so, something like this: { “pass”:“nomen”, “user”: “omen” } by Body row sender…)
How can I manage this?

1 Like

Hi, check out this thread for a guide how to configure the POST body schema in the Data Configurator:

Yes I’ve already read this but my task doesn’t work (I set the request schema of POST method with the corrects user and password but testing it give me back “Error: TypeError: NetworkError when attempting to fetch resource.status: -1 Resource settings for Create record (POST)” ).
Is it possible that the issue is because I use the POST method only to get data and no to store data?

I’ve also tried to define a custom response schema but nothing… :disappointed_relieved:

Hmm okay, if you open up Chrome Developer tools from the View menu and go to the Network tab, how does the request you’re making look like there? :slight_smile:

I think maybe my server is down at the moment (I’ll retry later to say you…), but how can I store a specify parameter that come through a POST method (in my case I receive the token like a parameter of an object nested into another object…) ? If I’ll use Set App Variable (in the logic of button API caller…) it wants a get call…isn’t it?

Good morning Mari
My call by browser/Postman perform well, but by AppGyver not yet…

Attached you find the network inspection

Hi, looks like you are getting a status 498 error from the server which means “Token expired/invalid”, so check again the token you are using in the request is correct and valid.

Yes I know, it’s not a problem.
First of all I want to be sure that it works well, after this I will pass token to have right data…but doing this I get of course data (invalid token message…)
The problem is that AppGyver geve me back “Error: TypeError: NetworkError when attempting to fetch resource.status: -1”
I’ve made an more detail inspection by Postman and I attach it below…(this is the POST call, it speaks about certification expired but it works fine…)

Hi, ahh I see. Was the screenshot you posted earlier after a Postman call or after clicking the “Test” button in Composer Data Configurator?

Hi, Let me explain; Here there is a the same call sent in the same time. Postman perform well but AppGyver give back error…

Hi, yes I understand the case, I was just thinking that there are two options here:

  1. Composer won’t accept a response with code 498, but throws a TypeError
  2. Something is incorrectly configured in Composer that is correct in Postman → the two calls will look different on the Network tab

That’s why I wanted to know if the 498 error also shows in the Network tab when you make the call from Composer. :slight_smile: If there is some other error going on, the code will be different.

…It’s very strange, because in Postman it is a good 200, and the Composer configuration it’s the same.
Now I notice that by Network tab (by browser inspection) when I send Composer “Run Test” honestly I get the right response into “Network → Response” tab but AppGyver tell me Status -1
It make me crazy :exploding_head:

Hmm, looks like you are getting a ‘CORS Missing Allow Origin’ there on the request – have you configured that on the backend? CORS issues don’t apply to Postman, that’s why the request might be working there and not in Composer.

I really don’t know, how could I fix this?
(I’ve already tried to run test with and without custom schema but nothing happens…)

Hi, that means that the backend might not be configured to allow requests from other origins, you need to fix it on the backend side:

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin

Hi Mari, first of all thank you for your support.

As you suggested I fixed “CORS Missing Allow Origin” issue on my browser.
( for other people with Firefox 87 you can mange directly it on “about:config” terminal or, easily installing “CORS Everywhere by spenibus” plugin. This is download link )

Unfortunately I didn’t solve yet :sleepy:. Now, by Data Configurator I get a “status ok” result (and I’m so happy :smile:), but testing it on mobile I get only an error :dizzy_face:( I use AppGyver testing app. I made a screenshot catching the error message into an alert…)

Hi, the reason it’s still not working on a phone is that installing a browser plugin just fixes the problem for that specific browser. You’ll need to change the configuration of the backend, or if you don’t have access to the backend, ask the owner of the backend to add the correct CORS headers there. :slight_smile:

Ok…so what I have to ask exactly to developers to solve this issue?Can you give me a right header? This because they told me that the certificate can’t to be different of self-signed, but maybe they could give me back a custom API header…

Hi, as per the instructions on this site sending a Access-Control-Allow-Origin: * header in the response will let the resource be accessed by any origin. You can also specify certain origins if you don’t want the resource to be accessible anywhere.

Hi, I was commenting based on the earlier screenshot you posted, where it says “CORS missing allow origin”. If you have the CORS everywhere browser add-on activated, it will add that header to the response.