forked from ArthurSrz/forge-data-position-final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
36 lines (32 loc) · 929 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
# Specify the necessary parameters
subdomain = "docs"
docId = "nSV5r7CLQCWzKqZCz7qBor"
tableId = "Form2"
api_url = f"https://{subdomain}.getgrist.com/api/docs/{docId}/tables/{tableId}/records"
api_key = "3a00dc02645f6f36f4e1c9449dd4a8529b5e9149"
# Set up the API key for authorization
headers = {
"Authorization": f"Bearer {api_key}"
}
# Prepare the request body
records = [
{
"fields": {"nom": "value1", "prenom": "value2"}
},
{
"fields": {"nom": "value3", "prenom": "value4"}
}
# Add more records as needed in the same format
]
data = {
"records": records
}
# Make the POST request
response = requests.post(api_url, headers=headers, json=data)
# Check the response status
if response.status_code == 200:
print("Records added successfully!")
else:
print("Error adding records. Status code:", response.status_code)
print("Error message:", response.text)