Skip to content

Commit 4727b7e

Browse files
authored
Merge branch 'v1.15' into docs-scheduler-etcd-flags
2 parents 576bd9a + 7307d8e commit 4727b7e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-cloudevents.md

+20
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,26 @@ with DaprClient() as client:
108108
topic_name='orders',
109109
publish_metadata={'cloudevent.id': 'd99b228f-6c73-4e78-8c4d-3f80a043d317', 'cloudevent.source': 'payment'}
110110
)
111+
112+
# or
113+
114+
cloud_event = {
115+
'specversion': '1.0',
116+
'type': 'com.example.event',
117+
'source': 'payment',
118+
'id': 'd99b228f-6c73-4e78-8c4d-3f80a043d317',
119+
'data': {'orderId': i},
120+
'datacontenttype': 'application/json',
121+
...
122+
}
123+
124+
# Set the data content type to 'application/cloudevents+json'
125+
result = client.publish_event(
126+
pubsub_name='order_pub_sub',
127+
topic_name='orders',
128+
data=json.dumps(cloud_event),
129+
data_content_type='application/cloudevents+json',
130+
)
111131
```
112132

113133
{{% /codetab %}}

0 commit comments

Comments
 (0)