Forum Discussion
Dataflows asks for credentials for each URL
- Anonymous4 years ago
I did actually solve it after I knew what to search for.
This is the M-code that did require a authentication validation for each combination in the url (I wanted anonymous):varApiName = "salesOrders?$expand=salesOrderLines",varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/" & varApiName ,varOptions = [Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),and this is the solution that prevented it:
varApiName = "salesOrders?$expand=salesOrderLines",varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/",varOptions = [RelativePath=varApiName, Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),The changes are in bold.
I don't do a lot with APIs but this ducumentation looks pretty detailed if you haven't seen it already.
https://docs.microsoft.com/en-us/power-query/handlingauthentication
I'd be surprised if you can't do it at the base level.
- Anonymous4 years agoNot applicable
Great documentation! Thank you. I am a bit unsure whether it can help me (see reply above) but it definitely gave me some ideas on how to proceed.
- KNP4 years agoSuper User
Can you share your Power Query code (hide anything sensitive obviously), it might help get you an answer.
- Anonymous4 years agoNot applicable
I did actually solve it after I knew what to search for.
This is the M-code that did require a authentication validation for each combination in the url (I wanted anonymous):varApiName = "salesOrders?$expand=salesOrderLines",varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/" & varApiName ,varOptions = [Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),and this is the solution that prevented it:
varApiName = "salesOrders?$expand=salesOrderLines",varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/",varOptions = [RelativePath=varApiName, Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),The changes are in bold.