cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
slackerhx Regular Visitor
Regular Visitor

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

Accepted Solutions
slackerhx Regular Visitor
Regular Visitor

Re: Need help on Rest API connection

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
Highlighted
slackerhx Regular Visitor
Regular Visitor

Re: Need help on Rest API connection

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.

slackerhx Regular Visitor
Regular Visitor

Re: Need help on Rest API connection

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

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 182 members 1,932 guests
Please welcome our newest community members: