Created
April 13, 2023 10:50
-
-
Save angelabauer/9ed3a297c0c28bb0821bf7bb55f62684 to your computer and use it in GitHub Desktop.
Solution for sheety.py for the Flight Club project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import os | |
BEARER = os.getenv("API_Bearer_Sheety_Repl.it") | |
USERNAME = os.getenv("API_Username_Sheety") | |
PROJECT = "flightDealsUsers" | |
SHEET = "users" | |
base_url = "https://api.sheety.co" | |
def post_new_row(first_name, last_name, email): | |
endpoint_url = f"/{USERNAME}/{PROJECT}/{SHEET}" | |
url = base_url + endpoint_url | |
headers = { | |
"Authorization": f"Bearer {BEARER}", | |
"Content-Type": "application/json", | |
} | |
body = { | |
"user": { | |
"firstName": first_name, | |
"lastName": last_name, | |
"email": email, | |
} | |
} | |
response = requests.post(url=url, headers=headers, json=body) | |
response.raise_for_status() | |
print(response.text) |
where do I find the API Username?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Dimon1358 @kashish-51 , instead of xxx , type in the characters you want and click save changes , now thats your token