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

Search Food GET Request always Status 200 but EMPTY JSON

ANSWERED

Hey all,

 

I hope somebody can help me. I want to do a GET request with the Search Foods Query (https://api.fitbit.com/1/foods/search.json). I always get status 200 and an empty JSON -> {"foods":[]}.

 

What am I doing wrong? It does not find any food I am looking for.

 

This is my code:

Function SearchFood(brand As String, Food As String) As Variant

Dim Url As String
Url = "https://api.fitbit.com/1/foods/search.json"

With FitBitService
    .Open "GET", Url
    .setRequestHeader "Authorization", "Bearer " & Setting.GetEntry("FitbitToken")
    .send ("query=" & Food)
    If .Status = 200 Then
        SearchFood = .responseText
    Else
        SearchFood = "Failed"
    End If
End With

End Function

 

 

 

Thanks in advance!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @Matthi1958

 

I'm wondering if your code is not adding the "?" prior to the query parameters.  I executed this endpoint and received data

 

https://api.fitbit.com/1/foods/search.json?query=oatmeal

 

Gordon 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
2 REPLIES 2

Hi @Matthi1958

 

I'm wondering if your code is not adding the "?" prior to the query parameters.  I executed this endpoint and received data

 

https://api.fitbit.com/1/foods/search.json?query=oatmeal

 

Gordon 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

Hey @Gordon-C

Thanks! Worked fine!

 

Best Answer
0 Votes