Forum Discussion
API authentication error on scheduled refresh!
I have a couple of API feeds which I connected through the web connector. These require an api key for authentication, I added this in the header using the advanced section.
The data refresh works fine on the desktop version but I have tried to set up a scheduled refresh and I am getting an authentication error. It seems as though it isn't pulling through the api key in the header:
I feel as though M might be the answer but i have little (to no) experience with M so any help would be appreciated!
Try this, substituting in your api key, and see if you see the same error
let
vBaseUrl = "https://api.projectmanager.com",
vPath = "api/v1/projects.json",
vHeaders = [ #"apikey"="this is where i put my key" ],
Source = Web.Contents ( vBaseUrl, [RelativePath=vPath, Headers=vHeaders] ),
Json = Json.Document ( Source )
in
Json
10 Replies
- blopez11Super User
For web service APIs, what works in the Desktop doesn't always work in the service
It is likely due to anonymous authentication not being supported for the URL in the error message
It would be helpful to see the M code used in your query, you can blur out the API key
- rdubsFrequent Visitor
Hi blopez11
thanks for the speedy response!
This is the M code:
let
Source = Json.Document(Web.Contents("https://api.projectmanager.com/api/v1/projects.json", [Headers=[apikey="this is where i put my key"]]))
in
Source- blopez11Super User
Try this, substituting in your api key, and see if you see the same error
let
vBaseUrl = "https://api.projectmanager.com",
vPath = "api/v1/projects.json",
vHeaders = [ #"apikey"="this is where i put my key" ],
Source = Web.Contents ( vBaseUrl, [RelativePath=vPath, Headers=vHeaders] ),
Json = Json.Document ( Source )
in
Json