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
slackerhx
Helper II
Helper II

Need help on Rest API connection

Hi All, 

 

I'm trying to create a tool that connects to Baidu Maps API to extract travel time data based on the different modes of transport. 

 

I've successfully manage to create a custom function that allows dynamic changes to Start and End destinations. However, results i get from Baidu maps is that the "App is not present, there is error in the AK" refer to Column D . When i tested the URL link in a blank webpage, it manage to return valid results for the Start and End locations if i typed in manually. However, if i copy the data from the cell into the URL, it gives error (shown below). Appreciate if anyone can enlighten on what went wrong. Thanks.

 

(Start as text, End as text) => 

let 

   Baidu_API_key = "API_key", 
   Distance_lite = Web.Contents("http://api.map.baidu.com/directionlite/v1/driving?origin=Start&destination=End&ak=Baidu_API_key"),
   Results = Json.Document(Distance_lite)

in

Results

Error.PNG

 

 

error 2.PNG

 

1 ACCEPTED SOLUTION

Hi All, 

 

my colleague helped to solve the above issue. It is crucial for the orign and destination inputs to omit spacing for the api to be connected correctly. Hence, instead of 22.543648, 113.947003 it should be 22.543648,113.947003.

View solution in original post

2 REPLIES 2
slackerhx
Helper II
Helper II

I've made modifications to my query function and its now pulling the same data as what is available on webpage. 

 

(Start as text, End as text) => 

let 

   Baidu_API_key = "APIkey", 
   Distance_lite = Web.Contents("http://api.map.baidu.com/directionlite/v1/transit?",
                   [Query=
                         [origin=Start,
                          destination=End,
                          ak=Baidu_API_key]]),
   Results = Json.Document(Distance_lite)

in

Results

I read the documentation for Baidu Directions Lite API again, it states that the format of origin needs to be Double, Double. (please see documentation here http://lbsyun.baidu.com/index.php?title=webapi/direction-api-v2)

 

Greatly appreciate if anyone can suggest a solution to pass the query inputs as number instead of string. I haven't figure out a way to pass the parameter as numbers when comma is involved. The example coordinates i've used were origin = 22.599244, 114.049508 | destination = 22.543648, 113.947003

 

Thank you.

Hi All, 

 

my colleague helped to solve the above issue. It is crucial for the orign and destination inputs to omit spacing for the api to be connected correctly. Hence, instead of 22.543648, 113.947003 it should be 22.543648,113.947003.

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.