Producing Messages with Rest API to Test Pulsar Functions

There are many ways to produce messages to a StreamNative cluster. The StreamNative UI provides code for many Pulsar client libraries, CLI Tools, and the Rest API. Since we are working with Python, you may be less inclined to configure a Java development environment. Instead, we will produce a sample message to the a topic using the Rest API and an API Key. Navigate to Pulsar Clients in the left pane of the StreamNative to view the many options. Select Rest API.

After selecting a service account, creating a new API Key, and selecting a tenant, namespace, and topic, Produce messages will have a fully configured curl command.

curl -X POST https://<SERVER ENDPOINT>/admin/rest/topics/v1/persistent/summitstudent1/developer/input1/message \
  --header 'Authorization: Bearer <API KEY HERE>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/octet-stream' \
  --data-binary 'Hi, Pulsar'

Keep a copy of this command handy. We will produce messages using the Rest API throughout the course. The only changes we will typically need to make are the topic name (e.g. input1 above) and the message sent to the server (e.g. “Hi, Pulsar” above).