Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the API to work #362

Closed
elssar opened this issue Feb 10, 2013 · 4 comments
Closed

Can't get the API to work #362

elssar opened this issue Feb 10, 2013 · 4 comments

Comments

@elssar
Copy link

elssar commented Feb 10, 2013

I'm having problems getting the API to work. I get a 200, with the data as html. But when I check my stats on the website, nothing has changed.

I'm using Python, and the requests library. My code is

req= post('https://habitapp.com/v1/users/<user-id>/tasks/<task-name>/up', data={'apiToken': <api-token>}, headers= {'user-agent': 'pyhabit', 'content-type': 'application/json'})

The response I get is -

>>> req.status_code
200
>>> req.headers
{'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'expires': 'Sun, 17 Feb 2013 13:07:37 GMT', 'vary': 'Accept-Encoding', 'server': 'nginx/1.2.6', 'last-modified': 'Sat, 09 Feb 2013 00:07:26 GMT', 'connection': 'keep-alive', 'etag': '"0-1360368446000"', 'cache-control': 'public, max-age=604800', 'date': 'Sun, 10 Feb 2013 13:07:37 GMT', 'x-powered-by': 'Express', 'content-type': 'text/html; charset=UTF-8'}

I thought it might be because task name, and task-id are different, so after a digging around, I found some habit-ids and tried using them in place of task name - didn't work either.

@lefnire
Copy link
Contributor

lefnire commented Feb 10, 2013

oh wow. yeah, everything looks right - it's definitely taskId instead of taskName (but if the task id doesn't exist in the system, it will create a new task with that id). I'll check into this

@elssar
Copy link
Author

elssar commented Feb 13, 2013

Oops, I didn't convert my payload to json.
I thought requests would automatically do that. Was wrong. Now it works.

@elssar elssar closed this as completed Feb 13, 2013
@switz
Copy link
Contributor

switz commented Feb 13, 2013

Well this is still an issue. It shouldn't return 200 for a malformed request. Looking into this.

@lefnire
Copy link
Contributor

lefnire commented Feb 13, 2013

had to enforce application/Json for api requests to bypass splash.html
On Feb 13, 2013 6:26 AM, "Daniel Saewitz" notifications@github.com wrote:

Well this is still an issue. It shouldn't return 200 for a malformed
request. Looking into this.


Reply to this email directly or view it on GitHubhttps://github.com//issues/362#issuecomment-13486447.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants