Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I've been stumping my head quite a lot with this, and can't figure out how to solve it.
I access a REST API and I have to send it a body to filter the json records that I need to get. I have got to make the GET calls without any problem, but can't get the POST ones to work.
This is the code at the moment:
let
credencial=Record.Field(GetToken2(),"token") as text,
query = "{
""from"":""2022-06-12T00:00:00.000Z"",
""to"":""2022-06-12T23:59:59.000Z"",
""onlyUnprocessed"":""false"",
""vehicles:""null"",
""drivers:""null"",
""alarms:2735687,
""severityLevels:""null""
}",
url = Text.Combine({"MYAPIURL/occurrencesextended?api_key=", credencial}),
Source = Json.Document(Web.Contents(url),[Content=Text.ToBinary(query)])
in
Source
But when running this query, it shows the next error:
And I haven't been able to find any post or article that guides me to how to solve this problem. There are some that are similar in the forum, but the issue they have is not the same as mine. Anybody has any insight?
Thanks in advance for your help.
Solved! Go to Solution.
Hi once again,
I managed to figure it out:
let
credencial=Record.Field(GetToken2(),"token") as text,
query = "{
""from"":""2022-07-07T00:00:00.000Z"",
""to"":""2022-07-07T23:59:59.000Z"",
""onlyUnprocessed"":false,
""vehicles"":""null"",
""drivers"":""null"",
""alarms"":2735687,
""severityLevels"":""null""
}",
url = Text.Combine({"MYAPIURL?api_key=", credencial}),
Source = Json.Document(Web.Contents(url,
[
Headers=[#"Content-Type"="application/json"],
Content= Text.ToBinary(query)
]))
in
Source
It seems it was about expliciting the application/json and some formatting enhancements in the Web.Contents() method.
Hope this can help somebody in the future, thanks to all who read my original post.
Hi once again,
I managed to figure it out:
let
credencial=Record.Field(GetToken2(),"token") as text,
query = "{
""from"":""2022-07-07T00:00:00.000Z"",
""to"":""2022-07-07T23:59:59.000Z"",
""onlyUnprocessed"":false,
""vehicles"":""null"",
""drivers"":""null"",
""alarms"":2735687,
""severityLevels"":""null""
}",
url = Text.Combine({"MYAPIURL?api_key=", credencial}),
Source = Json.Document(Web.Contents(url,
[
Headers=[#"Content-Type"="application/json"],
Content= Text.ToBinary(query)
]))
in
Source
It seems it was about expliciting the application/json and some formatting enhancements in the Web.Contents() method.
Hope this can help somebody in the future, thanks to all who read my original post.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
53 | |
21 | |
12 | |
12 |