Doubts with APIs

Hey guys, I’m stuck at integration of two APIs to my app.
I’ve followed this example How to use api in app
image

But in this API (F2b - API REST) I’m having this error:


Error code: 500

And in this API (Catálogo de Produtos, GTIN, NCM, Tributação e Marca - Cosmos) I’m having this error:


Error code: 401 (invalid token)

Can somebody please help? It has been 2 weeks struggling with it so far…

Bro its an error with the server not your blocks.

As the message sate that you are using invalid token ( moreover if I see the url then you are no even using any token)

Perhaps you have to get a token from the API provider to get access to the API

1 Like

No, they provide me the token and I am using It…

the API uses HTTP Basic Auth, which means the value in the Authorization header must be the text Basic followed by a space followed by your token

see also

btw. also you can remove the Host from the header…
Taifun

1 Like

I’ve made an app for testing purpose, would it be something like this?


The app retrieves the same error:

According to the API documentation available at Catálogo de Produtos, GTIN, NCM, Tributação e Marca - Cosmos

I’ve made a second app for testing the other API, here’s the blocks:

Here’s the print with error:

remove the : after Authorization
and add again the Content-Type

never use :
Taifun

The message as changed, now it says 2d instead 3a

without your blocks unfortunately nobody will be able to help…
Taifun

I removed the : from the other API and it is working now!

you are using one thread to describe problems with 2 different APIs which makes it difficult for others to follow what you are talking about… next time you might want to use 2 different threads…

so one of the issues seems to be solved now… can you provide a screenshot of the relevant blocks of the working solution?

and the last screenshot seems to be the blocks of the API, which still is not working…
you did not add the Content-Type header as suggested earlier…
also check your token and make sure, it is base64 encoded

Taifun

1 Like

Sorry for that, will do.

I added the blocks that where missing

I don’t know how to check if my token is base64 encoded, but it was provided by that platform.

Here’s the output

I used the tools from this site https://base64.guru/ and it tells me that my token is not a well formed base64 token, so they suggested the repair tool and I used it in my token and it generated a new token with a different format.
I replace my token by this new one and now the error has changed:


So now I think that it’s a issue with the token provided by the platform, not my code.
I’ll report this issue to them, meanwhile I would like to thank the community for the time and attention spent, hope the knowledge in this thread helps somebody in future!

your blocks are fine
probably the token you received was not base64 encoded? what you could try is to base64 encode your token and try again…

Taifun

It worked!
But I don’t know why they gave me a token that it’s not in the format that they use, such nonsense!
Thank you very much to help me overcome this issue Taifun!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.