Closed
Description
Using a very minimalistic event results in a non-worky cloud events:
vaikas-a01:sdk-python-master vaikas$ python3 ./app2.py
{'content-type': 'application/cloudevents+json'}
b'{"specversion": "1.0", "id": "my-id", "source": "from-vaikas", "type": "vaikas.test", "datacontenttype": "application/json", "data": "{\\"HELLO\\": \\"FROM VILLE\\"}", "extensions": {}}'
Workaround:
https://github.com/cloudevents/sdk-python/blob/master/cloudevents/sdk/event/v1.py#L31
Removing this line makes it work (but then you can't use extensions):
in v1.py
self.ce__extensions = opt.Option("extensions", dict(), False)
Repro code:
event = (
v1.Event().
SetContentType("application/json").
SetEventID("my-id").
SetSource("from-vaikas").
SetEventType("vaikas.test").
SetData('{"HELLO": "FROM VILLE"}')
)
m = marshaller.NewHTTPMarshaller(
[
structured.NewJSONHTTPCloudEventConverter()
]
)
#broker url
#url = 'http://localhost:8080/'
get headers and body
headers, body = m.ToRequest(event, converters.TypeStructured, lambda x: x)
print(headers)
print(body.getvalue())
#send the request
response = requests.post(url, headers=headers, data=body)
Metadata
Metadata
Assignees
Labels
No labels