Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Post to Fitbit API

Can anyone plese help? I have been trying to get this post code to work for two weeks. Can someone have a look a tell me what I need to do in order to post to the fitbit api? Thanks in advance.

 

urlworkout = "https://api.fitbit.com/1/user/-/body/log/weight.json";
 string postData = String.Format("weight={0}&date={1}", "69.99", "2015-08-13");
 byte[] bytedata = Encoding.UTF8.GetBytes(postData);
 HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(urlworkout);
 request2.Method = "POST";

request2.Headers["Authorization"] = "Bearer " + responseString; //This is the access token
 request2.ContentLength = bytedata.Length;
 request2.ContentType = "application/x-www-form-urlencoded";
 Stream requestStream = request2.GetRequestStream();
 requestStream.Write(bytedata, 0, bytedata.Length);
 requestStream.Close();

Best Answer
0 Votes
2 REPLIES 2

Out of curious, did you get 404 response?

Best Answer
0 Votes
No. I never got any error. It just did not work.
Best Answer
0 Votes