Good afternoon,
I'm using python to subscribe to topics using the requests
library (not the platform client SDK). I've tried to create the request body a number of different ways. I've tried data=data
and json=data
. I'm trying to subscribe to multiple topics at once. What is the right way?
Here is my latest attempt. I keep getting a 400 Bad request no matter what I do.
data = json.dumps({
"type": "subscribe",
"topics": topics,
"id": str(uuid.uuid4())
})
print(data, type(data))
uri = gencloud_auth[self.org_id]["api_uri"]
self.headers = {
"Authorization": f"{gencloud_auth[self.org_id]['token_type']} {gencloud_auth[self.org_id]['access_token']}",
"Content-Type": "application/json"
}
endpoint = f"/api/v2/notifications/channels/{self.channel_id}/subscriptions"
sub_uri = f"{uri}{endpoint}"
response = requests.put(sub_uri, headers=self.headers, json=data)
print(response)
if response.status_code >= 400:
print(response.text)
raise Exception(f"Error subscribing: {response.text}")