Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ryan_OC
Helper I
Helper I

Easy POST requests with Power BI and Power Query using Json.FromValue - Errors

Dear @ImkeF,

 

With reference to your topic in your blog: "Easy POST requests with Power BI and Power Query using Json.FromValue" - https://www.thebiccountant.com/2018/06/05/easy-post-requests-with-power-bi-and-power-query-using-jso... 

 

Firstly thank you the great help with this!

 

I seem to be getting some issues with my solution:

 

let
Source = (Records) =>
let
Key = “{API Key}”, //this is the API for the live environment
CompanyID = “XXXXXX”, //this is the company code
Method = “DetailedLedgerTransaction”, //this is from the Sage Accounting API Specification
WebAddress = “https://accounting.sageone.co.za/api/2.0.0/”, //This is the webaddress for the live environment
url = Json.Document(Web.Contents(WebAddress & Method & “/Get?apikey=” & Key & “&CompanyID=” & CompanyID)),
header = [#”Content-Type”=”application/json”,#”Accept”=”application/json”], //not sure about this header???
body = Json.FromValue([ Inactive = [ true ], Active = [ true ], FromAccount = {“”}, ToAccount = {“”}, IncludeNoTax = [ true ], FromDate = {“2021-12-30”}, ToDate = {“2021-12-30”}]),
Source = Json.Document(Web.Contents(url,[Headers = header,Content=body])
in
Source
in
Source

 

I get a "not allowed" error.

 

Any idea why I might be getting this?

Thanks in advance!

6 REPLIES 6
ImkeF
Community Champion
Community Champion

Hi @Ryan_OC 
that depends on the specifications of your API / which endpoint you want to address. 
You have to look that up in our API documentation.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF
Community Champion
Community Champion

Hi @Ryan_OC ,
I am surprised about all the hightlighted brackets in your code. Usually, I would expect to see "simple" strings in those positions:

let
Source = (Records) =>
let
Key = “{API Key}”, //this is the API for the live environment
CompanyID = “XXXXXX”, //this is the company code
Method = “DetailedLedgerTransaction”, //this is from the Sage Accounting API Specification
WebAddress = “https://accounting.sageone.co.za/api/2.0.0/”, //This is the webaddress for the live environment
url = Json.Document(Web.Contents(WebAddress & Method & “/Get?apikey=” & Key & “&CompanyID=” & CompanyID)),
header = [#”Content-Type”=”application/json”,#”Accept”=”application/json”], //not sure about this header???
body = Json.FromValue([ Inactive = [ true ], Active = [ true ], FromAccount = {“”}, ToAccount = {“”}, IncludeNoTax = [ true ], FromDate = {“2021-12-30”}, ToDate = {“2021-12-30”}]),
Source = Json.Document(Web.Contents(url,[Headers = header,Content=body])
in
Source
in
Source

 



Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks @ImkeF. To Be honest, I'm not sure about them at all... perhaps thats why I'm getting the errors? 

What would you expect to see?

 

Thanks

Anonymous
Not applicable

Hi @Ryan_OC ,

 

//I get a "not allowed" error.

Could you please post the full error message?

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Hi Gao, 

 

Any response here... I'm pretty desperate! 

 

@ImkeF Any chance you could weigh in here... ?

Hi Gao, 

 

The error message is as such:
An error occurred in the ‘Query1’ query. DataSource.Error: Web.Contents failed to get contents from 'https://accounting.sageone.co.za/api/2.0.0/DetailedLedgerTransaction/Get?apikey={API KEY}&CompanyID={Company ID}' (405): Method Not Allowed
Details:
DataSourceKind=Web
DataSourcePath=https://accounting.sageone.co.za/api/2.0.0/DetailedLedgerTransaction/Get
Url=https://accounting.sageone.co.za/api/2.0.0/DetailedLedgerTransaction/Get?apikey={API KEY}&CompanyID={Company ID}

 

Does this help?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors