Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Boleslaw
New Member

Power Query to access Open Route maps

Hello,

I am looking for help with my POST request in Power Query. I am trying to use matrix service but with no luck so far. I am receiving the following error:
DataSource.Error: Web.Contents failed to get contents from ‘https://api.openrouteservice.org/v2/matrix/driving-car/’ (400): Bad Request

Here is my code:
let
url = “https://api.openrouteservice.org/v2/matrix/driving-car/”,
headers = [#“Content-Type” = “application/json”,#“Accept”= “application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8”, #“Authorization”= “xxxxxxxxxxxxxxxx”],
postData = Json.FromValue([locations=“[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]]”]),
response = Web.Contents(
url,
[
Headers = headers,
Content = postData
]
),
jsonResponse = Json.Document(response)
in
jsonResponse

I presume the problem is with passing body argument using Json.FromValue

[locations=“[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]]”]

 

I would be greatful for any hint on how to solve this problem.

Thank you!

1 ACCEPTED SOLUTION
ams1
Super User
Super User

Hi @Boleslaw 

 

Yeah, in PowerQuery lists use "{" instead of "[":

 

...
postData = Json.FromValue([locations={{9.70093,48.477473},{9.207916,49.153868},{37.573242,55.801281},{115.663757,38.106467}}])
...

 

Please mark this as answer if it helped.

View solution in original post

2 REPLIES 2
Boleslaw
New Member

Great, thank you. This is the solution I was looking for....

ams1
Super User
Super User

Hi @Boleslaw 

 

Yeah, in PowerQuery lists use "{" instead of "[":

 

...
postData = Json.FromValue([locations={{9.70093,48.477473},{9.207916,49.153868},{37.573242,55.801281},{115.663757,38.106467}}])
...

 

Please mark this as answer if it helped.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors