mcaulifn / solcast

Apache License 2.0
7 stars 2 forks source link

post_measurements not working #46

Closed StefaE closed 3 years ago

StefaE commented 3 years ago

Description

RooftopSite.post_measurements() doesn't appear to work. Thanks to some kind help on the solcast forum, following three issues were identified:

  1. url needs authentication
  2. I didn't get it working with passing a dict to requests.post - rather, I had to pass a json string. Maybe there are ways to do that, but I didn't succeed.
  3. headers={ ‘Content-Type’:‘application/json’ } is needed

What I Did

see forum thread for my trial and the code which eventually resolved it.

That said: Thanks for your providing the library in the first place. I'm new to requests, so it gave me a great starting point and woking get requests in a breeze.

mcaulifn commented 3 years ago

@StefaE Thanks for catching this!

Per the request docs, changing the post in base.py L52 post(url, json=data) should resolve it. Can you give that a try? PRs are welcome if you get a chance. 😃

StefaE commented 3 years ago

nope - you need add authentication to the url (you do that for get, but not for post) and you need header Content-type. I'll make a code proposal later this week.

mcaulifn commented 3 years ago

I see the auth missing now. Please try out the branch I just created.

mcaulifn commented 3 years ago

After much trouble, v1.0.7 has been published to PyPI.