09-01-2015 09:09
09-01-2015 09:09
I am writing code to retrieve users fitbit data into my application. Is there any way for my users to make entries into my application and for my application to send it to fitbit?
09-01-2015 11:46
09-01-2015 11:46
What type of entries?
You can log activity: https://dev.fitbit.com/docs/activity/#log-activity
You can log weight: https://dev.fitbit.com/docs/body/#log-weight
You can log food: https://dev.fitbit.com/docs/food-logging/#logging-and-deleting-collection-data
You can log sleep: https://dev.fitbit.com/docs/sleep/#log-sleep
09-01-2015 14:33
09-01-2015 14:33
09-01-2015 14:34
09-01-2015 14:34
How do you get the user id to put in the POST https://api.fitbit.com/1/user/[user-id]/body/log/weight.json ?
09-01-2015 15:37
09-01-2015 15:37
@jschrimshire wrote:
Where do you get the user id to put in the url? The documentation says use the "-" for the current logged in user. I tried that and that does not work.
It's not the logged in user, but rather the OAuth access token for the user that you're sending in the Authorization header. You can check what user a token belongs to by requesting the profile.
09-01-2015 15:40
09-01-2015 15:40
@jschrimshire wrote:
How do you get the user id to put in the POST https://api.fitbit.com/1/user/[user-id]/body/log/weight.json ?
The user id is returned with the access token at the end of the OAuth process.
09-02-2015 11:41
09-02-2015 11:41
09-02-2015 13:51
09-02-2015 13:51
Does anyone have a code snippet that shows how to post user data such as weight to the fitbit api? The documentation gives very little details as to how to do this. If there was just a simple example of posting one item, then I could figure out the rest. This is so frustrating. Thanks in advance.
09-02-2015 15:29
09-02-2015 15:29
@jschrimshire wrote:
Is there any example as to how you actually do a post? Please don't point me to the documentation. That is written from a 30,000 ft view.
POST is one of the HTTP methods, sometimes called HTTP's verbs. Most HTTP libraries allow you to specify the HTTP method easily. I'd point you to documentation, but...*
If you were using cURL, the request might look like:
curl \ -X POST \ -H "Authorization: Bearer reallylongoauth.token.here" \ --data "weight=65.7&date=2015-09-02&time=15:23:00" \ https://api.fitbit.com/1/user/-/body/log/weight.json
* If you do want to learn about HTTP methods, MDN has a good introduction.
09-03-2015 07:35
09-03-2015 07:35
09-03-2015 13:35
09-03-2015 13:35
Did you try the example with cURL? If so, what was the server's response?
09-03-2015 14:02
09-03-2015 14:02
09-03-2015 17:08
09-03-2015 17:08
@jschrimshire wrote:
urlworkout = "https://api.fitbit.com/1/user/3MQRBF/body/log/weight/65.7/date/2015-08-13.json";
To create a weight log entry, the URL to POST to is https://api.fitbit.com/1/user/-/body/log/weight.json
Did you look at the server's response when you tried to use the URL in your example? It should have returned a HTTP 404 Not Found error, which lets you know when you're not using the correct URL.
09-04-2015 07:24
09-04-2015 07:24
09-04-2015 11:32
09-04-2015 11:32
@jschrimshire wrote:
As I asked for in my last email, it would be so helpful if you or someone could just provide an example code snippet that would make this work.
I provided a working cURL example earlier. I don't have a code example for the HTTP library that you're using.
@jschrimshire wrote:
No I do not get a 404 error or any error for that matter. It just does not log a weight.
The server returns some response. What is the response? Specifically, what is the HTTP status code and what is the body of the response say?
@jschrimshire wrote:
If you do not place the actual weight into the url, then where do you put it?
You put the information in the HTTP body as a form encoded values.
09-04-2015 12:14
09-04-2015 12:14