Forum Discussion

zoloturu's avatar
zoloturu
Memorable Member
8 years ago
Solved

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 ...
  • ImkeF's avatar
    ImkeF
    8 years ago

    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: 

  • zoloturu's avatar
    zoloturu
    8 years ago

    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
        result

    where AuthorizationToken, WorkspaceID and DatasetID are parameters.

     

     

    Regards,

    Ruslan