Closed hamrel-cxu closed 4 years ago
A 400 error can be caused by many things, the most common is an invalid set of query parameters. Does the response include a JSON object with a message providing validation error details?
Hey, I've got the the same over here, 400 bad request, here's the result (the email is valid, I just obfuscated it for obvious reasons):
{"inputs":{"names":"tmy","wkt":"POINT(-77.75 36.15)","mail":"xxx.xxx@xxx.com","interval":"60"},"metadata":{"version":"2.0.0"},"status":400,"errors":["The required 'email' parameter must be a valid email address"]}
@hazilo In your case it looks like you are providing a "mail" parameter, however the required parameter name is "email".
(edited) It was my bad, the one I copied and tried from my browser had the email truncated... In our software it is the correct "email" but still doing 400 bad request... from some tests it seems that you are not accepting post requests anymore?
We do support receiving POST requests. can you share an example POST request that is failing? With that I can debug and figure out what's causing the 400s.
https://developer.nrel.gov/api/solar/nsrdb_psm3_download.csv?api_key=xxx post parameters: api_key=xxx names=tmy wkt=POINT(Longitude Latitude) email=xxx@yyy.com interval=60
@hazilo I'm not able to reproduce this. Using a valid API key, email address, and wkt value and submitting a request like this via the POST method works for me. It may be something in the way you are formulating your request. Typically a 400 response will include some JSON with an error message... this message may offer a clue if some of your params are invalid. In my test I simply used URL params like so: https://developer.nrel.gov/api/solar/nsrdb_psm3_download.csv?names=tmy&wkt=POINT(-80 41)&email=paul.edwards@nrel.gov&interval=60&api_key={{api_key}} . You can also follow the examples at the bottom of this page for additional guidance: https://developer.nrel.gov/docs/solar/nsrdb/guide/
problem solved
@hazilo I'm not able to reproduce this. Using a valid API key, email address, and wkt value and submitting a request like this via the POST method works for me. It may be something in the way you are formulating your request. Typically a 400 response will include some JSON with an error message... this message may offer a clue if some of your params are invalid. In my test I simply used URL params like so: https://developer.nrel.gov/api/solar/nsrdb_psm3_download.csv?names=tmy&wkt=POINT(-80 41)&email=paul.edwards@nrel.gov&interval=60&api_key={{api_key}} . You can also follow the examples at the bottom of this page for additional guidance: https://developer.nrel.gov/docs/solar/nsrdb/guide/
@PjEdwards When I try this with POINT(-80 40) it works, but when I use POINT(32.49 -84.18), which is a latitude and longitude I have downloaded data from in the NSRDB Map Viewer itself, it gives me this error:
{ "inputs": { "names": "2000", "email": "myemail@gmail.com", "wkt": "POINT(32.49 -84.18)" }, "metadata": { "version": "1.0.0" }, "status": 400, "errors": [ "No data available at the provided location", "Data processing failure." ] } Why is it not giving me data for this location?
I was following the API instruction for Solar Data Download at this url (https://nsrdb.nrel.gov/data-sets/api-instructions.html), but after replacing the 'api_key' and 'your_email' with what I requested through https://developer.nrel.gov/signup/, I received the error message "HTTP Error 400: Bad Request". What happened and what can I do?
Thanks