0

I am new to use Google api nearest roads to snap the roads.

I was trying as in the below link:

Google api for nearest road

If I have to try the

https://roads.googleapis.com/v1/nearestRoads?parameters&key=YOUR_API_KEY

with the api key provided in my Project, I get

{
"error": {
    "code": 403,
    "message": "Roads API has not been used in project **** before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/roads/overview?project=*** then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
        {
            "@type": "type.googleapis.com/google.rpc.Help",
            "links": [
                {
                    "description": "Google developer console API activation",
                    "url": "https://console.developers.google.com/apis/api/roads/overview?project=****"
                }
            ]
        }
    ]
}

replaces the key used.

What am I missing here? Should I verify the key somewhere before using? Or if I want to just try out the samples how do I get the key?

3
  • 1
    The error message tells you to visit a URL to enable it. Did you do that? Commented May 29, 2018 at 9:07
  • If i try to vsiit that url, it asks me to login to google account, but i got this key from my clients
    – pgman
    Commented May 29, 2018 at 9:58
  • Then talk to your client. Commented May 29, 2018 at 11:08

1 Answer 1

1

"Roads API has not been used in project **** before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/roads/overview?project=*** then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",

This error message is a little confusing. Before you can access an API you need to enable it in your project on Google developer console. To do that

  1. Go to https://console.developers.google.com/apis/dashboard
  2. make sure your project is selected at the top.
  3. Go to library
  4. search for roads api
  5. Enable it.

Wait a few minutes and your code should then work

Detailed info:

When you want to access Google data google needs to know who you are. And what your project will be doing. They do that by asking you to create a project on google developer console. In that project you can define the apis you will be using and you can also request api keys and client ids which will allow you to access data. In this instance you are having an issue with the set up of your project on google developer console it has nothing to do with your code.

2
  • selecting my project in the sense should i select the actual project that i code in? Also when i try to go to dashboard, it asks me to sign in... so should i use my gmail account? since am using my work related project am bit confused here
    – pgman
    Commented May 29, 2018 at 9:24
  • 1
    Your project is already slected in your code google knows what project the key is linked to. This is an issue in the setup of your project on Google developer console. You should sign in with what ever account you used to create the project that the API key you are currently using linked to. Commented May 29, 2018 at 9:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.