headers:
- x-app-id
- x-app-key
- Content-Type: application/json
POST request body:
{
"query":"ran 3 miles",
"gender":"female",
"weight_kg":72.5,
"height_cm":167.64,
"age":30
}
See comment below for sample API response.
Original documentation: https://docs.google.com/document/d/1_q-K-ObMTZvO0qUEAxROrN3bwMujwAN25sLHwJzliK0/edit#
`import requests
import os
query = input("Enter your exercise data: ")
gender = "male"
age = 17
weight = 57
height = 172
app_id = os.environ.get('AppID')
api_key = os.environ.get('APIKey')
print(app_id)
print(api_key)
nutrition_endpoint = "https://trackapi.nutritionix.com/v2/natural/exercise"
nutrition_headers = {
"x-app-id": app_id,
"x-app-key": api_key,
"Content-Type": "json"
}
nutrition_json = {
"query": query,
"gender": gender,
"age": age,
"weight_kg": weight,
}
response = requests.post(url=nutrition_endpoint,
json=nutrition_json,
headers=nutrition_headers)
print(response.status_code)
print(response.json())`
when i run this code i get status_code has 400 and {'message': 'child "query" fails because ["query" is required]', 'id': '39cc0948-0fe9-4fd8-8cb4-adb731dd2431'}