File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 77API_KEY = os .environ .get ("API_KEY" , "API_KEY it doesn't exist" )
88
99# 2 Get Exercise stats with NLQ
10- response = requests .post (
11- 'https://trackapi.nutritionix.com/v2/natural/exercise' ,
12- headers = {
13- "x-app-id" : APP_ID ,
14- "x-app-key" : API_KEY
15- }, params = {
16- "query" : "swam for 1 hour"
17- })
10+ url = "https://trackapi.nutritionix.com/v2/natural/exercise"
11+ headers = {
12+ "Content-Type" : "application/json" ,
13+ "x-app-id" : APP_ID ,
14+ "x-app-key" : API_KEY
15+ }
1816
19- print (response )
17+ data = {
18+ "query" : "swam for 1 hour"
19+ }
20+
21+ response = requests .post (url , headers = headers , json = data )
22+ if response .status_code == 200 :
23+ response = response .json ()
24+ print (response )
25+ else :
26+ print (f"Error in the request. Status code: { response .status_code } " )
27+ print (response .text )
2028
2129# 3 Setup Google Sheet with Sheety
2230
You can’t perform that action at this time.
0 commit comments