Mit Python -Anforderungen (Web -API) kann keine Verbindung zu GridDB Cloud hergestellt werden - Verbindungsfehler erhaltPython

Python-Programme
Anonymous
 Mit Python -Anforderungen (Web -API) kann keine Verbindung zu GridDB Cloud hergestellt werden - Verbindungsfehler erhalt

Post by Anonymous »

Ich versuche mit der Web -API eine Verbindung zu GridDB -Cloud von Python herzustellen. Ich bin neu in der Web -API. Bitte helfen Sie. Ich habe den Endpunkt und die Anmeldeinformationen bereits durch die tatsächlichen Werte aus meinem GridDB -Cloud -Portal ersetzt.

Code: Select all

# Replace these with your actual GridDB Cloud details
BASE = "https://cloud5197.griddb.com:443/griddb/v2/clustername/dbs/dbname"  # replace with your endpoint
AUTH = ("userid", "password")  # replace with your credentials

r = requests.get(f"{BASE}/ping", auth=AUTH, timeout=10)
print("Status code:", r.status_code)
print("Response text:", r.text)

container_def = {
"name": "iot_data",
"columns": [
{"name": "device_id", "type": "STRING"},
{"name": "ts", "type": "TIMESTAMP"},
{"name": "temp", "type": "DOUBLE"}
],
"containerType": "COLLECTION",  # or TIMESERIES depending on plan
"rowKey": ["device_id", "ts"]
}

r = requests.post(f"{BASE}/containers", auth=AUTH, json=container_def)
print("create container:", r.status_code, r.text)

# 2) Insert a row
row = {"device_id":"dev-01","ts":"2025-09-20T12:00:00Z","temp":23.5}
r = requests.post(f"{BASE}/containers/iot_data/rows", auth=AUTH, json=row)
print("insert row:", r.status_code, r.text)

# 3) Query rows (simple GET)
r = requests.get(f"{BASE}/containers/iot_data/rows", auth=AUTH)
print("rows:", r.status_code, r.text)
< /code>

I Replaced the endpoint and credentials from my GridDB Cloud portal and email.

Traceback/Response

I am not got an error , like the code runs successfully but I get following :
Status code: 403
Response text: 
403 Forbidden

403 Forbidden
Microsoft-Azure-Application-Gateway/v2



create container: 403 
403 Forbidden

403 Forbidden
Microsoft-Azure-Application-Gateway/v2



insert row: 403 
403 Forbidden

403 Forbidden
Microsoft-Azure-Application-Gateway/v2



rows: 403 
403 Forbidden

403 Forbidden
Microsoft-Azure-Application-Gateway/v2



Question
•   Is there any additional configuration needed to access GridDB Cloud REST API (like IP whitelist, SSL certificate, or proxy)?
•   Has anyone successfully connected using Python requests?
•   Is my endpoint format correct ?

Environment
•   OS: Windows 11
•   Python: 3.12
•   Library: requests 2.32
•   IDE: Visual Studio Code

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post