How to POST logical type decimal values for Avro records to Confluent Rest Proxy?

473 views Asked by At

We are using the Confluent Rest Proxy to communicate with Kafka and need to test a variety of data. We are using the Rest Proxy to allow a vendor to communicate with our Kafka system.

One of our fields in the Avro schema has a logical type of decimal. To keep this simple, let's assume the schema shown here:

{
  "fields": [
    {
      "name": "fieldName",
      "type": "string"
    },
    {
      "name": "amount",
      "type": {
        "logicalType": "decimal",
        "precision": 16,
        "scale": 2,
        "type": "bytes"
      }
    }
  ],
  "name": "Sample",
  "namespace": "com.test.sample",
  "type": "record"
}

It's easy enough to write to the topic via a Java producer, using Avro Tools to produce the appropriate class files. But when attempting to use the Rest Proxy, we have to pass values such as this:

{"value_schema_id":132,"records": [{"value":{"fieldName":"Field Name","amount":"\u0001ã"}}]}

This was copied from a record created via the Java producer and then downloaded from the topic. But in the amount field, we'd like to be able to pass a value such as 123.45. We're using Postman for the most part to send data. Is there a way to do this with a logical decimal field and without having to create and serialize the data first to see the representation such as \u0001ã?

0

There are 0 answers