Forum Discussion
How to run POST request in M?
Dear community,
I know that Power BI is for ETL, but I'm interested in understanding of all capabilities of it.
Did somebody send a POST request to run some action using M (Power Query)?
For instance this one - https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/refreshdatasetingroup
Regards,
Ruslan
Adding an empty string as the Content-parameter does the trick for me:
Content=Text.ToBinary("")Although the query will then return an error. the refresh actually was successful:
Hi ImkeF,
You are correct. It is working for me as well. Thank you!
And to avoid this error we need to add any extra step to return some value.
Here is the final code for this case:
let vToken = AuthorizationToken, vUrl = "https://api.powerbi.com/v1.0/myorg/groups/" & WorkspaceID & "/datasets/" & DatasetID & "/refreshes", Source = Json.Document(Web.Contents(vUrl, [Headers=[Authorization=vToken],Content=Text.ToBinary("")])), result = 1 in resultwhere AuthorizationToken, WorkspaceID and DatasetID are parameters.
Regards,
Ruslan
8 Replies
- ImkeFCommunity Champion
Hi zoloturu,
I've described how this worked for me here: https://www.thebiccountant.com/2018/06/05/easy-post-requests-with-power-bi-and-power-query-using-json-fromvalue/
- zoloturuMemorable Member
Hi ImkeF,
Thank you for this information. But my case is different.
I have two requests which are completely the same, only difference is how you run it - GET or POST:
1. Datasets - Get Refresh History In Group (GET)
https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetKey}/refresheshttps://docs.microsoft.com/en-us/rest/api/power-bi/datasets/refreshdatasetingroup
2. Datasets - Refresh Dataset In Group (POST)
https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetKey}/refresheshttps://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getrefreshhistoryingroup
How to run the second one in Power Query?
Regards,
Ruslan- ImkeFCommunity Champion
Adding an empty string as the Content-parameter does the trick for me:
Content=Text.ToBinary("")Although the query will then return an error. the refresh actually was successful: