Skip to content

Commit 875ea85

Browse files
committed
fix request
1 parent ff38439 commit 875ea85

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

WorkoutTracking/main.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@
77
API_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

0 commit comments

Comments
 (0)