POST /topics/{topic:string}

Produces messages into a topic with the following behavior.

Description

Depending on the configuration, the type of information retrieved has different behavior. See the streams.default.stream and rest.proxy.backend parameters in Configuration Parameters

Table 1. Response Behavior
Parameters Defined Response
streams.default.stream is defined

Produces messages into specific MapR Streams topics. If the topic name does not contain a stream path, then the default stream path is used.

streams.default.stream is not defined and rest.proxy.backend=streams

Produces messages into a MapR Streams topic. The topic name should contain a stream path and be encoded.

streams.default.stream is not defined and rest.proxy.backend=hybrid

Produces messages into a MapR Streams topic if the topic name starts with a forward slash (/) and contains a colon (:). Otherwise, messages are produced into an Apache Kafka topic.

Note: If the topic does not exist, the following error results: [“error_code”:40401, “message”: ”Topic not found.”}. New topics are not created by the POST operation.
Table 2. Parameters
Parameters Description
topic_name (string) Name of the topic to produce the messages to.

Syntax

http://<host>:8082/topics/<topic_string>

Request Example

This example produces a message using binary embedded data with the value, Kafka, to the topic, test.

curl -X POST -H "Content-Type: application/vnd.kafka.binary.v1+json" --data '{"records":[{"value":"S2Fma2E="}]}' "http://localhost:8082/topics/test"

Response Example

{"offsets":
    [{
        "partition":0, 
        "offset": 1,
        "error_code":null,
        "error":null
      }],
  "key_schema_id":null,
  "value_schema_id":null
}