Forum Discussion
Help with POST API
Hi smeredith ,
If I understand your sceanrio correctly that you want to get data with the REST API in power bi desktop?
If so, please refer to the similar threads firstly.
https://community.powerbi.com/t5/Desktop/How-to-run-POST-request-in-M/td-p/457138
If you need any other help, free to ask.
Best Regards,
Cherry
Thank you for the information. I have made several attempts, but generally fail with the 405 Method not allowed error. Presently I am only trying to receive the bearer token from the URL using basic auth.
Attempt 1:
let
Source = Json.Document(Web.Contents("https://forneyvaultapi-v5staging.azurewebsites.net/api/Authenticate"))
in
Source
Attempt 2:
let
auth_key ="Basic ZWRlbmlubm92YXBpQGZvcm5leXZhdWx0LmNvbTpjcUBebV8rQmhnNl5laEdQ",
url = "https://forneyvaultapi-v5staging.azurewebsites.net/api/Authenticate",
header =[#"Authorization"=auth_key,
#"Content-Type"="application/json; charset=utf-8"],
content1="{
[email protected],
password=password
}",
webdata1=Web.Contents(url, [Headers=header,Content=Text.ToBinary(content1)]),
response1=Json.Document(webdata1)
in
response1
Attempt 3:
let
authkey="Basic ZWRlbmlubm92YXBpQGZvcm5leXZhdWx0LmNvbTpjcUBebV8rQmhnNl5laEdQ",
url = "https://forneyvaultapi-v5staging.azurewebsites.net/api/Authenticate",
source = Json.Document(Web.Contents(url,[Headers = [Authorization = authkey, #"content-type" = "application/json:charset = utf-8"]]))
in
source
Attempt 4:
let
url="https://forneyvaultapi-v5staging.azurewebsites.net/api/Authenticate",
auth_key = "BASIC ZWRlbmlubm92YXBpQGZvcm5leXZhdWx0LmNvbTpjcUBebV8rQmhnNl5laEdQ",
header= [
#"Content-Type" = "application/json; charset=utf-8",
#"Authorization" = auth_key,
#"Accept"="*/*",
#"Cache-Control"="no-cache",
#"Host"="forneyvaultapi-v5staging.azurewebsites.net",
#"Accept-Encoding"="gzip, deflate",
#"Content-Length"=84,
#"Connection"="keep-alive"
],
webdata = Web.Contents(url),
response = Json.Document(webdata)
in
response
Attempt 5:
let
url="https://forneyvaultapi-v5staging.azurewebsites.net/api/Authenticate",
header= [
#"Content-Type" = "application/json",
#"Authorization" = auth_key,
#"Accept"="*/*",
#"Cache-Control"="no-cache",
#"Host"="forneyvaultapi-v5staging.azurewebsites.net",
#"Accept-Encoding"="gzip, deflate",
#"Content-Length"=84,
#"Cookie"="ARRAffinity=84bf4a47daca0e8b2456e7f9b916668a7467930da7d6cbd0753e915d0fcce476",
#"Connection"="keep-alive",
#"username"="[email protected]",
#"password"="password"
],
auth_key = "BASIC ZWRlbmlubm92YXBpQGZvcm5leXZhdWx0LmNvbTpjcUBebV8rQmhnNl5laEdQ",
body="{""username"":""[email protected]"",""password"":""password""}",
webdata = Web.Contents(url),
response = Json.Document(webdata)
in
response
Attempt 6:
let
url="https://forneyvaultapi-v5staging.azurewebsites.net/api/Authenticate",
body="{""username"":""[email protected]"",""password"":""password""}",
Source = Json.Document(Web.Contents(url,[Headers= [
#"Content-Type" = "application/json",
#"Authorization" = auth_key,
#"Accept"="*/*",
#"Cache-Control"="no-cache",
#"Accept-Encoding"="gzip, deflate",
#"Cookie"="ARRAffinity=84bf4a47daca0e8b2456e7f9b916668a7467930da7d6cbd0753e915d0fcce476",
#"Connection"="keep-alive",
#"username"="[email protected]",
#"password"="password"
]])),
auth_key = "BASIC ZWRlbmlubm92YXBpQGZvcm5leXZhdWx0LmNvbTpjcUBebV8rQmhnNl5laEdQ"
in
#"Source"