Forum Discussion
M Query to use POST method on a Web API
.
Hi,
Thanks for the response.
I have the Sage One documentation and have updated my query to:
let
body=
"{
""FromDate"": ""2017-01-01"",
""ToDate"": ""2018-01-01""
}",
Source = Json.Document(Web.Contents(url,[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] ))
in Source
but Im getting this error:
DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
DataSourceKind=Web
DataSourcePath=https://accounting.sageone.co.za/api/1.1.2/AccountBalance/Get
Can you advise?
Thanks
Digiroo
- Eric_Zhang9 years ago
Microsoft Employee
digiroo wrote:
Hi,
Thanks for the response.
I have the Sage One documentation and have updated my query to:
let
body=
"{
""FromDate"": ""2017-01-01"",
""ToDate"": ""2018-01-01""
}",Source = Json.Document(Web.Contents(url,[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] ))
in Source
but Im getting this error:
DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
DataSourceKind=Web
DataSourcePath=https://accounting.sageone.co.za/api/1.1.2/AccountBalance/GetCan you advise?
Thanks
Digiroo
That seems the limitation of Power Query, check this link https://social.technet.microsoft.com/Forums/en-US/6366dd5d-302c-42fb-8283-c833954c3858/sending-contents-to-windows-authenticated-service-results-in-an-error-content-option-is-only?forum=powerquery
Isn't there any authentication key(#"Authorization"=AuthKey in header) for the API? If not, what's going on when setting an empty Authorization?
- Anonymous9 years agoNot applicable
did you make it work?
could you please share your code here? I am also having trouble on my API.
- marco_lima9 years agoFrequent Visitor
let
Source = Xml.Tables (Web.Contents("http://webapi", [Content=Text.ToBinary("")]))
in Source
In this case for XML if you know how to do it in Json or Csv it would be nice to show as well.
- digiroo9 years agoFrequent Visitor
I can see a reported bug on the Power BI Support page.
Users are unable to edit credentials for data sources in reports and unable to refresh the datasets. Power BI team is aware of the issue and are working on a fix. Next update 01/18/2017 09:30 PST.
Is this issue related?