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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

POST query with authorization token

Hi, I'm trying to post info into a DB using an endpoint, but It's not working, this is the query:

 

 

 

 

let
        data = Json.FromValue([ fieldName="someData"]),
        Source = Json.Document(Web.Contents("https://url", [Headers=[Authorization="authorization token", #"Content-Type"="application/json"], Content=data]))
in
    Source

 

 

 

 

If I remove the Content from the source, I'm able to get the whole record from the table, but as soon I add the content It show this error:

 

 

 

 

DataSource.Error: Web.Contents failed to get contents from 'https://myURL' (404): Not Found
Details:
    DataSourceKind=Web
    DataSourcePath=https://myURL
    Url=https://myURL

 

 

 

 

Thanks in advanced.

6 REPLIES 6
Anonymous
Not applicable

Thanks @Daryl-Lynch-Bzy @but that is pretty much what we need to do: writing to a database.

 

I watch this video and that's what I'm trying to do. I have tried with a free API and works fine.

 

https://youtu.be/4dJ2vobI-G8

 

Thanks @Anonymous - I think you need to change this step:

 data = Text.FromBinary( Json.FromValue( [fieldName="someData"] ) )
Anonymous
Not applicable

I tried without Text.FromBinary, just Json.FromValue and the error remains

Sorry - I sure how to help.  Can you double check that Json is properly formatted by using VS Code or Postman.  Obtain the Json from the Text.FromBinary step and past it into another tool to see if the error is occurring.

Anonymous
Not applicable

This is the code using JsonPlaceHolder API:

let
    data = Json.FromValue([title = "ID_WERTPAPIER", body = "851399", userId = "US" ]),
    outputdata = Text.FromBinary(data),
    Source = Json.Document(Web.Contents("https://jsonplaceholder.typicode.com/posts", [Headers=[#"Content-Type"="application/json"], Content=data]))
in
    Source

And it works!!! But if I use my own API, adding authorization to the header, something goes wrong, now the error message is this:

 

Expression.Error: We cannot convert a value of type Binary to type Text.
Details:
Value=[Binary]
Type=[Type]

 

I know that my endpoint is working cause it works in postman.

Daryl-Lynch-Bzy
Community Champion
Community Champion

Hi @Anonymous - what you mean by "post info into a DB"?  You should not use Power Query to write data into a database.  It is not recommended because Power Query could send the transactions multiple times to the database.

 

You also mention that API works without the Content.  This suggests that the API call is GET type.  It is not sual for url string to work as GET call and POST call - it is normally one or the other.  Can you provide more details on the API.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.