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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
LeonLiang
Frequent Visitor

How can I call api with post method in Power BI?

Hi Folks,

 

Suppose I have an api, https://testurl.com/api/getOrderList, how can I use it with post method and my basic auth information in Power BI to get my order list data? 

 

Thanks in advance!

Leon

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @LeonLiang ,

 

If you want to make a POST request to a web service through Power Query, you have to add the relevant data in the “Content”-parameter of the query . Please refer to:

web-services-and-post-requests-in-power-query 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Liang,

 

I didn't vote this as a solution. How come it became a solution?

 

I tried to format my request as following:


let
    start_date = Number.From(Date.From("01-01-2021")),

    // or  start_date = "01-01-2021"

    // or start_date = "2021-01-01"
    PostContents = start_date,
    Source = Json.Document(Web.Contents("https://testurl.com/api/getOrderList"),         [Content=Text.ToBinary(PostContents)])
in
    Source

 

 

It tells me the following error

LeonLiang_0-1629286292060.png

 

Not sure how to solve this problem?

 

Leon

 

Hi @LeonLiang ,

 

In your code,  start_date is a number. You need to convert it into text to see if it works

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Any updates?

Hi Liang,

 

I already tried bunch of convert methods whereas they all failed. Do you have a straight forward solution?

 

Cheers

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.