Hello,
I’m trying to get data from my Topic via my API client, but I’m receiving an “Invalid Route” response.
Here is my “Get” verb request:
https://api.confluent.cloud/v1/clusters/lkc-57rvon/topics/ccc_topic_0/records
Please advise.
Thank you,
Ken
Hi there! I just want to confirm what you’re trying to do here. The title of your post says “sending data to the topic” which implies you want a producer. But the body of the post suggests you want to get data from the topic, which implies a consumer.
Please clarify so we can advise! Thanks!
Hi Danica,
Sorry for the confusion.
I actually want to do both. I want to first send the data in a Post request and then retreive the data in a Get request.
Thanks,
Ken
Okay, it seems like I’m getting closer to successfully Producing Data to my Topic, but now I’m getting error code 200:
{
“error_code”: 200,
“cluster_id”: “lkc-57rvon”,
“topic_name”: “ccc_topic_0”,
“partition_id”: 5,
“offset”: 0,
“timestamp”: “2022-10-15T12:40:03.949Z”,
“value”: {
“type”: “JSON”,
“size”: 12
}
}
Here’s my Rest Client:
var client = new RestClient(“https://pkc-6ojv2.us-west4.gcp.confluent.cloud:443/kafka/v3/clusters/lkc-57rvon/topics/ccc_topic_0/records”);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader(“Authorization”, “Basic NVYyVlE3R003N09TUE1WUzpqRmUzSmxEUmNJd0tuc052QS9KSGgrUzJDcE1uTk91alJzZVBJSStGL0VxRWl2RFMzYjJldUZWNjIzWVlZNmVm”);
request.AddHeader(“Content-Type”, “application/json”);
var body = @“{”“value”“: {”“type”“: ““JSON””, ““data””: ““Hello Ken!””}}”;
request.AddParameter(“application/json”, body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Okay, I’m able to successfully send data to the topic using my Rest API client.
Can you please provide me an example demonstrating how to retreive data from my topic using a Rest API client.
It appears you are using C#? Why not use KafkaConsumer directly?