Power Automate - HTTP API Authorization

I’m trying to query the API using an HTTP action in Power Automate but I’m having trouble getting the authorization / apikey to work. I saw some documentation to use an Authorization Header with Basic (encoded APIKey:X) like below:

Capture1

When I trigger it, I get a 401 / invalid credentials error:

{
“code”: “invalid_credentials”,
“message”: “You have to be logged in to perform this action.”
}

I take it my syntax is wrong for the Authorization header - any ideas?

Thanks!

Hi @NeallM360,

Welcome to our Community! :tada:

Yes, as you have mentioned, the authorization header should be in the format of the Base64 encoded string of “<API_KEY>:X”.

Could you check if that happens rightly in the base64 function that has been inserted in the “Authorization” headers field? If possible, can you provide that function here to check?

Also, please check the same API in the cURL request to make sure the provided authorization user has access to the content.

Thanks! Yes I tried it in curl and it works.

Here is the function:

image

@NeallM360 I’ve not worked on the MS Power Automate before.
We do not have any experts from the same platform here.

Based on your input that it works fine in cURL with the same URL and API Key, the function and other template in the URL is perfectly replacing the right values, I think.

Is it possible to troubleshoot the outcome of these templates and find what’s actually being sent from these requests to match it with your cURL request?

I found a workaround. It seems to be an issue when putting the base64 function in the authorization header. My workaround was to create a variable to do the base64 encoding and then use that in the header. It works now.

Thanks!

1 Like

Thank you for sharing it @NeallM360 :smile:

This topic was automatically closed after 2 days. New replies are no longer allowed.