AstronomyAPI / Samples

Examples for Astronomy API
https://astronomyapi.com
MIT License
30 stars 3 forks source link

Format for payload bodies positions- help required #54

Closed jddavisuk closed 1 year ago

jddavisuk commented 1 year ago

When trying in python:

conn = http.client.HTTPSConnection("api.astronomyapi.com") headers = { 'Authorization': "Basic "my deleted login"} payload = '{"latitude":{52.775867},"longitude":{-2.39733},"elevation":{10},"from_date":{2023-05-21},"to_date":{2023-05-22},"time":{10:54:00},"output":{table}}' conn.request("GET", "/api/v2/bodies/positions", payload,headers=headers)

I get a 422 error response which seems to indicate a problem with my query payload.

Can you please tell me what is wrong with my payload format

Thanks

John D

astroanu commented 1 year ago

Hi, sorry was on vacation. I think you're not passing the query params correctly.

Since this is a GET request you can try something like this:

conn.request("GET", "/api/v2/bodies/positions?latitude=52.775867&longitude=-2.39733... .add all the other query params in the same way.....",headers=headers)

Don't forget to url encode your values with

jddavisuk commented 1 year ago

Thanks - your solution above solved my issue.