API Data Source & API Action - Different settings?

HI guys, hope you can help me out with that connection problem.

Using the same settings for API Datasource and API Action.
API Datasource works great but API Action shows:

Server returned code: 401
Unauthorized request

For authorization I use Bearer Token in API Headers
Name: authorization
Value: ‘Bearer PP…’

image

Guess it’s both on client side?

yep

I spotted a flaw on server-side api and raised a bug, not sure if its related as urs is on client-side…

Raise a bug with steps to reproduce…

Thank you, so you mean that it is a bug by wappler?

And what do you mean with “Raise a bug with steps to reproduce…”

I would really love to work with wappler (and of course purchase it)

But if the server side connection with my API (using Directus with MySQL) doesnt work, I cannot use it.

Using direct MySQL Connection is not a solution for me.

Personally I can not see why it would not work client side as well as server side, could you give much more detail and possibly some screenshots of what you are trying to do.
I can try replicate the procedure if I knew what APIs you are trying to connect to etc.

Also on the client side it happens, choosing API Data Source it works, while working with API Action it does not. I´m using exactly the same url and bearer token.

See my little GIF Video

in the GIF (Video) you can see that after klicking “Define API Schema” in API Action there is no header authorization but in the API Data Source yes

@George can you help me please.

I just purchased the software but now I cant use it because I cannot set the API Action correctly it seams.

I will try find some time over the weekend to do some testing for this but it does seem to require a bit of a setup to get this started and i just have not found the time.

Just looking at your gif though I do see that the Header is not shown as a parameter in the schema window.

Taking a total wild guess before testing personally I think because your API Action is using GET you should not be passing headers, that is more meant for POST, therefore according to the API documentation on Directus you should rather add your token to your URL parameter.


So according to that you should keep your API Data Source as is, and change your API Action to remove the header and rather add to the end of the URL as a query parameter with ?access_token=PP… not ?access_token=Bearer PP…

Please let me know if that helps at all, but basically with using GET i really think your need the query parameter and not a header.

1 Like

YEAH!

Thats it - now it works

Thank you @psweb

1 Like

Awesome, glad you got it working now, unfortunately with API stuff it is always difficult and you have some fiddling around to do because every API works so differently from each other with a few rules that all sort of follow similar guidelines.

1 Like

This thread helps me out so much = ] Ive been a long time user of https://cloudron.io/ They have a nice LAMP stack APP that I have been hosting all of my Wappler projects on but it also looks like Directus will be packed and available sooner than later! - ive been studying up on how Wappler handles API’s mainly auth so thanks for this clarification +1