Do Google Maps APIs also accept HTTP POST requests? - google-maps

I am very new to web development and using any google services api.
I know I can send HTTP GET with the following format:
http://maps.googleapis.com/maps/api/geocode/json?address=CA
I am reading the documentation and it seems that it only talks about HTTP GET requests:
https://developers.google.com/maps/web-services/overview
Does anyone have any experience sending HTTP POST request to google maps apis or it is just not accepted?

Based on the Google Maps API documentation https://developers.google.com/maps/web-services/overview you don't have the option to send POST requests but only GET.
Now as your post doesn't provide more infos on how you tried to do it, my suggestion is to create a middleware that will handle those requests.
This is kinda of onverengineering as the parameters will still appear to the user if you are trying to redirect them but it will be a good case if you don't.
You can create a simple node.js middleware that will have a POST API that you'll send the data the way you want and within this request in the middleware you will transform the data and send them with a GET method to the Gmaps Api.
You can use Express to create a middleware without a lot of effort.
You can read more here: https://expressjs.com/en/guide/writing-middleware.html

Related

Google Maps API is never satisfied

If I use URL referrer authentication with Geocoding API it says:
There was an error while trying to fix the Venues geolocation information: API keys with referer restrictions cannot be used with this API.
Which after research I find that this means that Google Maps is looking for IP address authentication.
But if I use IP address authentication with Javascript Maps API it says:
JavaScript API error: RefererNotAllowedMapError
https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error
Your site URL to be authorized: https://example.com
What can be going on?
How can I fully satisfy the good ol'Google Maps?
It looks like you're using two different Maps APIs; the client-side JavaScript API and the server-side Geocoding API web service. This means you need 2 API keys; one restricted with HTTP referrers for client-side use, and the other one restricted by IP address for web services only.
To learn more on how API key restrictions work check out Google's documentation on API key best practices.
Hope this helps!
I know this is 3 months old now. But I had the same problem and I found out how to solve this.
As evan said, you need 2 API Keys. And annoyingly, The Events Calendar only have one field for the API Key.
BUT, I found a link here: https://support.theeventscalendar.com/ to https://support.theeventscalendar.com/716190-Using-Google-Maps-API-Key-Restrictions. The page redirects though... But I managed to screen shot parts of it before it redirects and found this snippet: https://gist.github.com/cliffordp/a2ec320313afbc1ffb5f0e5ac654b7fb
(I changed the code to use a define instead because I don't want my API key in git)
This filter will make it possible to have two API KEYS.

Google Maps API: You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console

Doing some stress / load testing I got this message and figured out that I'm using the free version of the API and not the one available to us in our Google Premium Plan. We do have a clientId and a crypto key, but we are not sure on how to use them in the URL for proper authentication.
Could anyone please provide hints on such?
If you need to apply a client ID and digital signature in web service requests you should follow this documentation:
https://developers.google.com/maps/premium/previous-licenses/webservices/auth
If you need to authenticate Maps JavaScript API the documentations is here:
https://developers.google.com/maps/premium/previous-licenses/clientside/auth
For load testing you can use a mock API instead of the real one. This way you won't consume your map credits.
Please read about load testing of Google Maps APIs here:
https://developers.google.com/maps/premium/prelaunch-checklist#load_testing
Hope it helps!

Proper formatting for NASA API request URL

EDIT: NASA data can be accessed via the SODA API (see https://data.nasa.gov/developer), and the API referred to below seems to be deprecated.
I'm trying to use the NASA API (http://nasa.github.io/api-docs/#introduction) to pull information on NASA patents. The docs show what the JSON reponse should look like and list required parameters for the request, but I can't find any examples of a properly formed request URL. So far I have tried (with my API key):
https://api.nasa.gov/patents/optics?api_key=API_KEY
https://api.nasa.gov/patents/optics.json?api_key=API_KEY
I tested the API key out on an example GET request URL for a different data.gov agency and it returned a valid JSON response, but I've had no luck with the NASA requests.
Does anyone know the proper request format for NASA info from the data.gov API?
I think that there may be a be a better api to use that is actually on NASA's site here: https://data.nasa.gov/developer.
If you scroll down to "NASA Patents" you can see some documentation on how to use the api and a few sample requests to get you started, including how to filter on specific fields.
Reading the API documentation, it would seem that the category name (like optics in your example), should be passed a query parameter, not as part of URI as you are showing. I also don't see noted where they say they support https (of course I just skimmed the API). Try,
http://api.nasa.gov/patents?category=optics&api_key=API_KEY

Record all request uris/methods/response codes for Google Drive Java Client Library

I'm using the google client library to access the Google Drive API. I'd like to custom log all the request URI's, the request method as well as the response codes. Is there a built in mechanism to do this with the google client library?
Ideally, I could use the API as I am now and not have to modify each request but maybe add some sort of interceptor to the Drive object itself where I can record this data on every request that goes through this Drive service.
Any ideas?
Not sure that is exactly what you want but you could modify the log level of the API client in logging.properties
com.google.api.client.level = FINEST

Migrating to Drive SDK from DocumentsList API V3

I just came to know that DocumentsList API is depricated. So i thought of migrating my app to Drive and saw this page. I mostly use urls like https://docs.google.com/feeds/default/private/full/. So is it enough to replace them with new URL's like this https://www.googleapis.com/drive/v2/files/ ?
Just wanted to confirm is that all i need to takecare or am I missing anything. My App uses OAuth2 for authorization. Do I need to change anything in there too?
If you are constructing the requests yourself, you have to replace the URLs but also take into account that the responses from the Drive API will be JSON-formatted and not XML-formatted as in the Documents List API.
If instead you are using one of the Google-provided client libraries, you have to start using a newer client library, that you can download from https://developers.google.com/drive/downloads.
The migration guide is mostly a guide that maps methods from the Documents List API into methods of the Drive API and should be used as reference to know what is available and where.
Oauth 2.0 is fine. You can even use the same tokens you already have for Documents List v3.