Sign in | Sign up

difficult with v2/natural/nutrients

Tagged:

Currently contains 4 posts

Avatar

June 19, 2017 08:03

thesilverbail

Hi,

1.
I tried using the following python code to hit the v2 endpoint. I get “child \”query\" fails because [\“query\” is required]". What am I doing wrong?

import requests
import json

url = ‘https://trackapi.nutritionix.com/v2/natural/nutrients’
headers={ “x-app-id”: “<my id>”,
“x-app-key”: “<my key>”
}
params={ “query”: “grilled cheese” }
response = requests.post(url, headers=headers, params=params)
print response.text

2. I then tried the following code to hit the search/instant endpoint, it gave me results but there were no “common” foods, only “branded” foods. Again, what am i doing wrong?

import requests
import json

url = ‘https://trackapi.nutritionix.com/v2/search/instant?query=grilled%20cheese’
headers={ “x-app-id”: “<my id>”,
“x-app-key”: “<my key>”}
response = requests.get(url, headers=headers)

Thanks
Deepak

Avatar

April 19, 2018 07:28

ivanfantang

i have similar issue with you, did you get fixed?

Avatar

June 06, 2018 02:19

jhbuchel

I’m having the same issue.

Avatar

June 06, 2018 13:22

varungupta

“Params” pass the data as query string parameters. The natural endpoint requires the data to be passed via the body.

Reply to thread