Forum Discussion
SomeDataDude
Advocate I
4 years agoConnecting API
Hello, I've read through several posts here but can't figure it out. I want to realize an API connection in Power BI. I have a GET API and a POST API. I can't get both to work. For the POST API I...
- 4 years ago
I have found the solution. The following M code works for the API:
let content = "{ ""mode"" : ""raw"", ""ColCoCode"": ""00"", ""PayerNumber"" : ""AA00000000"", ""InvoiceStatus"": ""A"", ""FromDate"":""2021-12-12"", ""PageSize"":""-1"" }", Source = Json.Document(Web.Contents("https://url.api", [Headers=[#"Authorization"="Basic****", #"apikey" = "****", #"ContentType"="application/json"], ManualStatusHandling = {404, 400}, Content=Text.ToBinary(content)])) in Source
parry2k
Super User
4 years agoSomeDataDude not sure why you have authentication type in the header since you are using API Key.
✨ Follow us on LinkedIn and to our YouTube channel
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
SomeDataDude
Advocate I
4 years agoparry2k without the authentication I get the following message: Please specify how to connect
let
URL = "https://url.com",
headers = [#"Content-Type"="application/json"],
data = Json.FromValue([apiKey = "MyApiKey"]),
web = Web.Contents(URL, [ Content = data, Headers = headers, ManualStatusHandling = {404, 400}]),
result = Json.Document(web)
in
result