Skip to content

Instantly share code, notes, and snippets.

@angelabauer
Created April 13, 2023 10:50
Show Gist options
  • Save angelabauer/9ed3a297c0c28bb0821bf7bb55f62684 to your computer and use it in GitHub Desktop.
Save angelabauer/9ed3a297c0c28bb0821bf7bb55f62684 to your computer and use it in GitHub Desktop.
Solution for sheety.py for the Flight Club project
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)
@Dimon1358
Copy link

How to get bearer api ?

obraz

@MohamedHelmyCG
Copy link

@Dimon1358 @kashish-51 , instead of xxx , type in the characters you want and click save changes , now thats your token

@jawhelan
Copy link

where do I find the API Username?

@Musbi8788
Copy link

where do I find the API Username?

Picture1
you will find your api {API}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment