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
Anonymous
Not applicable

Call Rest API from Advanced Editor

I'm new to PowerBI and have a simple web API i typically call in python.  I used the Advanced Editor in PowerBI.  It it telling the syntax is good, but then i get the error:  "Expression.Error: We cannot convert a value of type Record to type Number.
Details: Value=[Record] Type=[Type]"

 

thank you.

Here is my code in Advanced Editor:

let

    apiUrl = "http://someserver:7979/v1/completed_detail",

    body = "{""submission_id"" :""01-25-2021-15-47-25""}",

    result = Json.Document(apiUrl, [Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body)])

in

    #"result"



 

5 REPLIES 5
Anonymous
Not applicable

I've tried to use Web.Contents() like this:

let

    apiUrl = "http://someserver:7979/v1/completed_detail",

    body = "{""submission_id"" :""01-25-2021-15-47-25""}",

    result = Json.Document(Web.Contents(apiUrl, [Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body)]))

in

    #"result"

But getting error:

DataSource.Error: Web.Contents failed to get contents from 'http://someserver:7979/v1/completed_detail' (405): METHOD NOT ALLOWED
Details:
    DataSourceKind=Web
    DataSourcePath=http://someserver:7979/v1/completed_detail
    Url=http://someserver:7979/v1/completed_detail

Hi @Anonymous ,

Not certain but the query looks like correct. Seems that could not send post request to the web source. Make sure whether the URL is accessible or need authentication and try it again. 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the update.  Hard to troubleshoot it though.  It looks correct.  I assume you've confirmed through the documentation for the API you are using that the syntax is correct (e.g., method completed_detail is an option and submission_id has hyphens).

 

FYI that you can also create the JSON for your body step with

= Json.FromValue([submission_id = "01-25-2021-15-47-25"])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Microsoft Employee
Microsoft Employee

You need to use Web.Contents() to make the web call with Header, Content first, and then you can extract the data with Json.Document.  Use Web.Contents in place of Json.Document and then go from there.

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat - i just posted my updated code.  thank you

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.