Showing results for 
Search instead for 
Did you mean: 
Advocate II
Advocate II

Dataset Refresh API doesn't work from Power Query

Hi there,

I'm trying to implement a Power Query Script that refresh a dataset by using "Dataset - Refresh Dataset in Group" REST API (

I can trigger the dataset refresh by using Postman or direct using the "Try it" API page (, but when I call for this API by using Power Query at Power BI Desktop, it just doesn't work.
Bellow is Power Query Script, where GetAccessToken is a separated Query that calls for Microsft API in order to retrieve a valid Token. It's working fine. I can say that because when I use the token return by GetAccessToken query and use it at Postman, it works.


    auto_token = "Bearer " & GetAccessToken,
    url_datasetlist = "",
    content_type = "application/x-www-form-urlencoded",
    Source = Json.Document(Web.Contents(url_datasetlist, [Headers=[Authorization=auto_token, #"Content-Type"=content_type, Content=body]]))


Source content is a record as you can see below:




Could any body help me find the problem? Any tip of what I'm doing wrong?


Community Support
Community Support

Hi @trt18-sistemas ,


It seems that the issue is with the content_type parameter in the header. The content_type parameter should be set to "application/json" instead of "application/x-www-form-urlencoded". Try changing the content_type parameter to "application/json" and see if that resolves the issue.

Try the modified code:

    auto_token = "Bearer " & GetAccessToken,
    url_datasetlist = "",
    content_type = "application/json",
    body = "{""notifyOption"": ""MailOnCompletion""}",
    Source = Json.Document(Web.Contents(url_datasetlist, [Headers=[Authorization=auto_token, #"Content-Type"=content_type], Content=Text.ToBinary(body)]))



Best Regards,

Stephen Tao


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

Hi @v-stephen-msft ,

Thanks for your reply. I forget to mention that I've tried using Json and it returned a error. I've pasted your code on Power BI and the same error pop up again (message below). In this case, seems that the problem is how message is formated, but I can't see any thing wrong on the content.



Just in case, here is the print screen from my M code:




Helpful resources

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors