无法通过 Kafka REST 生成 Confluent Kafka 主题 API

Can't produce to Confluent Kafka topic through Kafka REST API

我无法通过 Rest API 代理生成 Kafka 主题。

我有一个 运行 融合的 kafka 集群,我想在其中创建一个主题并使用 REST API.

向它生成一条消息

为此,我按照文档创建了 API 密钥和秘密。

我创建了主题:

curl -X POST -H "Authorization: Basic <BASE64_ENCODED_AUTH_KEY_SECRET>"  \
-H "Content-Type: application/json" \
-d "{\"topic_name\":\"test1\",\"partitions_count\":6,\"configs\":[]}" \
https://pkc-xmzwx.europe-central2.gcp.confluent.cloud:443/kafka/v3/clusters/lkc-1zoqz/topics" | jq 

-------------------
returns:
{
  "kind": "KafkaTopic",
  "metadata": {
    "self": "https://pkc-xmzwx.europe-central2.gcp.confluent.cloud/kafka/v3/clusters/lkc-1zoqz/topics/test1",
    "resource_name": "crn:///kafka=lkc-1zoqz/topic=test1"
  },
  "cluster_id": "lkc-1zoqz",
  "topic_name": "test1",
  "is_internal": false,
  "replication_factor": 0,
  "partitions_count": 0,
  "partitions": {
    "related": "https://pkc-xmzwx.europe-central2.gcp.confluent.cloud/kafka/v3/clusters/lkc-1zoqz/topics/test1/partitions"
  },
  "configs": {
    "related": "https://pkc-xmzwx.europe-central2.gcp.confluent.cloud/kafka/v3/clusters/lkc-1zoqz/topics/test1/configs"
  },
  "partition_reassignments": {
    "related": "https://pkc-xmzwx.europe-central2.gcp.confluent.cloud/kafka/v3/clusters/lkc-1zoqz/topics/test1/partitions/-/reassignment"
  },
  "authorized_operations": []
}

我的问题: 我无法生成该主题(无法通过 Kafka Rest 生成任何主题 API):

curl -X POST -H "Authorization: Basic <BASE64_ENCODED_AUTH_KEY_SECRET>"  \
-H "Content-Type: application/json" \
--data "{"records":[{"value":"S2Fma2E="}]}" \
"https://pkc-xmzwx.europe-central2.gcp.confluent.cloud:443/kafka/v3/clusters/lkc-1zoqz/topics/test1"  
    

-----------------
returns:
    {"error_code":405,"message":"HTTP 405 Method Not Allowed"}

也试过这样:

curl -X POST -H "Authorization: Basic <BASE64_ENCODED_AUTH_KEY_SECRET>"  \
                   -H "Content-Type: application/json" \
                    -d  "{ \"key\": {\"value\": \"S2Fma2E=\"} }" \
                   "https://pkc-xmzwx.europe-central2.gcp.confluent.cloud:443/kafka/v3/clusters/lkc-1zoqz/topics/test1/records"  

----------------
Returns the same:

    {"error_code":405,"message":"HTTP 405 Method Not Allowed"}

IDK这跟ACL管理有关系吗?现在正在调查....

您使用的是 Confluent Platform(托管)还是 Confluent Cloud API?

如果是后者,则此 API 不受支持,这里是有关 Cloud API 支持内容的文档:https://docs.confluent.io/cloud/current/api.html