Solved

API trigger to broadcast a flow

  • 15 September 2023
  • 1 reply
  • 65 views

Hi,

 

I’ve been trying to trigger a broadcast flow through an API call in python 

The documentation says to follow the following steps:

import http.clientconn = http.client.HTTPSConnection("api.customer.io")payload = "{\"data\":{\"headline\":\"Roadrunner spotted in Albuquerque!\",\"date\":1511315635,\"text\":\"We received reports of a roadrunner in your immediate area! Head to your dashboard to view more information!\"},\"email_add_duplicates\":false,\"email_ignore_missing\":false,\"id_ignore_missing\":false}"headers = {    'content-type': "application/json",    'Authorization': "Bearer REPLACE_BEARER_TOKEN"    }conn.request("POST", "/v1/campaigns/{broadcast_id}/triggers", payload, headers)res = conn.getresponse()data = res.read()print(data.decode("utf-8"))

I replaced the bearer token by an app API key and the broadcast_id but I got the following error : {"errors":[{"detail":"wrong datacenter","status":"301"}]}

It seems strange to me that there is no spot to specify the workspace I want to reach etc…

If you have any clue lmk !

 

Have a nice day !

icon

Best answer by Penny 18 September 2023, 07:20

View original

1 reply

Userlevel 4

Hi @caps_j,

 

It looks like you might be using this particular API endpoint: https://customer.io/docs/api/app/?region=eu#operation/triggerBroadcast.

 

If we navigate to the top left corner of the documentation page, you can select EU for your Region:

 

This will provide the EU endpoints for the sample payload (specifically in bold below would be the Europe data center):

 

import http.client

conn = http.client.HTTPSConnection("api-eu.customer.io")

payload = "{\"data\":{\"headline\":\"Roadrunner spotted in Albuquerque!\",\"date\":1511315635,\"text\":\"We received reports of a roadrunner in your immediate area! Head to your dashboard to view more information!\"},\"email_add_duplicates\":false,\"email_ignore_missing\":false,\"id_ignore_missing\":false}"

headers = {     'content-type': "application/json",     'Authorization': "Bearer REPLACE_BEARER_TOKEN"     }

conn.request("POST", "/v1/campaigns/{broadcast_id}/triggers", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

 

Hopefully this helps to clarify! ◡̈ 

Reply