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

Problem when i get weight data from API with unit of measurement

ANSWERED

i need to get data from Fitbit API with US unit measure my code has fix value in en_US but i receive Kilogram

 

it doesn't Pound. 

 

private RestRequest CreateRestRequest(string apiCall, Method method = Method.GET)
        {
            var request = new RestRequest(apiCall, method);

            // Always no cache
            request.AddHeader("Cache-Control", "no-cache");
            request.AddHeader("Accept-Language", "en_US");
            return request;
        }

 is these correct for add information on header ? 

 

ps . My profile changed to 'Pound' when i scale on Aria.

 

Thank you. 🙂

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

What exactAPI endpoint are you calling. I just tested https://api.fitbit.com/1/user/-/body/log/weight/date/<date>.json and it worked for me with Accept-Language: en_US header it responded in pounds.

Ivan Bahdanau
Senior Software Developer at Fitbit

View best answer in original post

Best Answer
0 Votes
3 REPLIES 3

What exactAPI endpoint are you calling. I just tested https://api.fitbit.com/1/user/-/body/log/weight/date/<date>.json and it worked for me with Accept-Language: en_US header it responded in pounds.

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes

i called 'API-Get-Time-Series' and respect type '[/body/weight]'.Before i call API i prepare request object like these. (below)

 

var request = CreateRestRequest(requestUrl);

            request.AddHeader("Accept-Language", "en_US");
            
            request.OnBeforeDeserialization = resp =>
                {
                    // Set root element
                    var data = (JsonObject) SimpleJson.DeserializeObject(resp.Content);
                    if (data != null && data.Any())
                    {
                        var root = data.FirstOrDefault();
                        request.RootElement = root.Key;
                    }
                };

 

Best Answer
0 Votes

i found my problem. Thank you for answer 🙂 

 

the problem is 'wrong step of add header'.

Best Answer
0 Votes