Forum Discussion

crossover's avatar
crossover
Advocate I
5 years ago
Solved

POST request and JSON body with several elements

HI! I'm in uncharted waters here, but hoping to find some help. I'm trying to create an end-user tool to run HTTP POST requests for entering new records in REST API over PowerQuery. The general usage...
  • ImkeF's avatar
    ImkeF
    5 years ago

    Hello crossover ,

    you have to use the M-syntax if you want to use Json.FromValue like so:

    let
        Source = Json.Document(Web.Contents(
               "https://myservice.com/api/tasks/",
               [
               
                Headers = [#"Authorization"= MyToken,
                #"Content-Type"="application/json"],
        
                Content=Json.FromValue([account = "https://myservice.com/api/tasks/accounts/123/", address = [raw_address = "10 greetings from Estonia"]])       
               ]
        ))
    in
        Source

     

    Alterntatively, the Text.ToBinary-function would would with the original JSON syntax like so:

    Content= Text.ToBinary("{""account"":""https://myservice.com/api/tasks/accounts/123/"",""address"":{""raw_address"":""10 greetings from Estonia""}}")