How do you use openrouteservice API?


I'm trying to create an app that has locations on the list and users can choose one and show it on the map. For this, I want to use openrouteservice API. I tried to use it as it is described in the MIT app inventor reference, but I didn't get back the 200 status code. What did I miss here?

Here is my code: Screenshot 2021-09-29 at 13-27-57 MIT App Inventor

Many thanks!

Are you signed up to use ORS?

You are attempting to use the OpenRoutService api with a Get control. I see nothing in your Blocks that indicates you signed up and acquired an API key. The key is needed to access the different endpoints that make up the openrouteservice.

While it should be possible to access ORS using the api, the easiest way to use ORS with App Inventor 2 is to use the Navigate control. Navigate provides direct access to the ORS api.

HOW TO: Use the Navigate control to use OpenRouteService.

Note that ORS works best with an OpenStreetMap, not a Google Map.

Hi, yes I have, in the showPlaceOnMap function set web1.utl to join ""

You use your 'my-api-key' and substitute the long text string.

What status code did the GotText block return? Label.text = responseCode can be used to display the status code you certainly do receive. Knowing the responseCode or Label.text = responseType might tell you where to look for your issue.

Did you do the Navigate tutorial? You should be able to use your 'my-api-key' string. If you can use your api key in the tutorial but not in your example, I expect an issue with your GotText code. Sorry, I cannot fix your code. You can or use the Navigate instead of using the api directly. I do see several potential issues with your code: Using a Notifier in the Block possibly causes issues, possibly a timing issue; calling showPlaceOnMap with the ListPicker.Selection might be causing your response code 200 to fail. What happens if you instead set the Web1.Url to the actual link " " filling in your actual key? That results in ""Daily quota reached or API key unauthorized"" because the actual key is not there but typing that in a browser should produce a result.

Some more alternatives are discussed here: