I'm trying to specify data formats and HTTP headers to ensure valid requests are submitted to the Kafka Bridge using Strimzi Kafka.
Message format When sending messages using the /topics endpoint, you enter the message payload in the request body, in the records parameter.
The records parameter can contain any of these optional fields:
Message headers
Message key
Message value
**Sample code in Python **
import requests
headers = {'content-type': 'application/vnd.kafka.json.v2+json', }
data = '{ "records": [ { "key": "key-1", "value": "value-1" }, { "key": "key-2", "value": "value-2" } ] }'
response = requests.post('http://localhost:54304/topics/my-topic', headers=headers, data=data)
So I need to modified the sample JSON API payload so that it matches the data format in the request body where data = '{....}'.
Sample JSON API: http://api.open-notify.org/astros.json
Output
{ "message": "success", "number": 11, "people": [ { "name": "Mike Hopkins", "craft": "ISS" }, { "name": "Victor Glover", "craft": "ISS" }, { "name": "Shannon Walker", "craft": "ISS" }, { "name": "Soichi Noguchi", "craft": "ISS" }, { "name": "Mark Vande Hei", "craft": "ISS" }, { "name": "Oleg Novitskiy", "craft": "ISS" }, { "name": "Pyotr Dubrov", "craft": "ISS" }, { "name": "Thomas Pesquet", "craft": "ISS" }, { "name": "Megan McArthur", "craft": "ISS" }, { "name": "Shane Kimbrough", "craft": "ISS" }, { "name": "Akihiko Hoshide", "craft": "ISS" } ] }
Please how do I format the JSON payload into a data structure for producing messages?