Error connecting to external API with Wappler

Wappler Version : 1.9.7
Operating System : Windows 10

Expected behavior

What do you think should happen?

It should make a connection to this API.

Actual behavior

What actually happens?

I get an error: Authorization required

How to reproduce

  1. I tested the API connection in Postman first, no problems there getting a response.

  2. I then entered the exact same information (URL, headers etc) in to Wappler, and then did a fetch. No problems so far, fetch worked fine.

  3. When trying to execute the server connect on the live site, I’m getting an error when checking the network tab within ‘inspect element’ in Chrome.

I have contacted the application where I’m connecting to, but their logs say they haven’t received any requests, and so it must be on our server side. I can connect to the API with Postman, just not with Wappler somehow.

Hi Nevil,
Are you sure your Authorization header value is actually inserted in the server action (not only where you fetch data) and also is it valid?

Yes it seems that the most recent version of wappler automatically retrieves the data of the headers section to the fetch window, so I didn’t change anything there. I didn’t manually fill in that field in fetch.

And so when the fetch works fine, it’s strange that the actual live version doesn’t work. This is btw the only api that has this, I’ve tried several other api’s and they all work fine.

Can you try removing the authorization header, add it again, save the server action and upload it to your server - does it make any difference?

No difference :cry: should I send an error report?

@Teodor is this now a known bug on your side, or do you need anything from me?

This doesn’t really look like a bug to me.
Can you share some link where i can inspect what’s going on maybe?

Yes: http://api.naturalheroes.nl/data/sync.php

Click the button “inventory planner”

My guess is that the value for the authorization header is incorrect, did you put quotes around the value?

I have tried double and single quotes in the value field just now, makes no difference.

The odd thing is that fetch API schema works fine. Also connecting with the exact same credentials using Postman works fine.

@patrick any other idea what we can do?

You can test with https://requestinspector.com. Just generate an hook there and change the url of your API action, then you can see what the actual data is that is send to the endpoint.

Yes I know this, but that isn’t solving the problem.

Knipsel

This is all correct.

Again, it works fine when I use postman, just not in Wappler. I’m pretty sure I’ve done everything like I’m supposed to. Is there anything you can check on your side?

Is it possible that the api checks more then only the authorization header, maybe it doesn’t like the user-agent or only allows ajax requests.

Yes I had already checked this, they only require application/json, and the account & authorization headers.

Again, using the exact same headers in Postman works fine.

Did you test the server connect action on a different server, like a local wamp/mamp server?

5 posts were split to a new topic: Error using API Data Source

I just did test this from another server, got the same problem. But then I contacted the developer of this API, they told me they received the header name in lower case, while they required it to be with the first letter as a capital letter. They corrected this on their side, and then I could connect again.

So my question is, does Wappler convert all header names/values to lower case?

Good that you figured out what was wrong and that they could solve that in the API. The headers are normally not case sensitive, Wappler doesn’t convert them to lowercase, the problem is the HTML DOM. We use standard HTML DOM in App Connect, so components are just tags and attributes, problem is that the DOM is not case sensitive, and it returns all attribute names in lowercase. That is why it was converted, we will have a look on how to improve this.

1 Like