Forum Discussion
crossover
5 years agoAdvocate I
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...
- 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 SourceAlterntatively, 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""}}")
ImkeF
5 years agoCommunity Champion
Hi crossover ,
just create the nested object in Power Query and then use the Json.FromValue function to transform it into the format for your call: Easy POST requests with Power BI and Power Query using Json.FromValue – The BIccountant