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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
shelly_sethi
Frequent Visitor

Post call on Rest API in M Code

Hello All,

 

I have an API and want to get the details on Post.

Although I am able to write the code with the help of community.But I want to make it dynamic to pick up the data from API whenever somebody posts into it.

 

Below is the code: The one marked in red,I don't want to hardcode the values.I want to take these values dynamically from the API.

Please help.

*********

let
url = "https://api.somevendor.com/api/",
headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "application/json"],
postData = "Any sort of text data you want to post to the API",
response = Web.Contents(
url,
[
Headers = headers,
Content = Text.ToBinary(postData)
]
),
jsonResponse = Json.Document(response)
in
jsonResponse

 

Cheers

Shelly

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @shelly_sethi 

Your question is confusing.  When you POST data you are typically writing/sending data to something.  You are talking about getting data from the API in order to POST it to the API?

Please clairify exactly what you are trying to do.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hello Philip,

 

I want the data from API into Power BI,API will be refreshed daily and it will have one day data.The goal is to extract data daily and put into some table.I am planning to set up incermental refresh on that table based on the  daily data update.

I have written below M code but here I have harcoded(in red) the values for testing purposes.How to make these values to be dynamic so that as soon as data changes it should fetch latest records.

 

let
url = "https://XXXXXi/TXXXX/XXXXX",
headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "application/json"],
postData = "{""serial"":[""B62035173B2540"",""9504BB57FB2613"",""D0E1A667E1951629F"",""C154A4691E62682EE"",""D371A621CE2B6E21""]}",
response = Web.Contents(
url,
[
Headers = headers,
Content = Text.ToBinary(postData)
]
),
jsonResponse = Json.Document(response)

 

Also if you could suggest ,it is possible to set up incremental refresh on this ...I don't know how will it work.

 

Thanks

Shelly

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.