Hi all,
I have created a Confluent Cloud Cluster and I am trying to publish events to the Kafka topic using the REST HTTP endpoint of the cluster.
Does anyone have an example of how to do that?
I used AWS Step Functions and Lambda to trigger the record creation but did not get any error and also did not see any messages in the topic.
private static async Task<Task<HttpStatusCode>> SendEventToTopic(String content)
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", "xxxxxxxxxxxx");
HttpContent httpContent = new StringContent(content, Encoding.UTF8);
var stringTask = client.PostAsync("https://xxxxxxxxxxxx.aws.confluent.cloud:443/kafka/v3/clusters/xcxcxcxcx/topics/payments.json.events/records", httpContent);
var msg = stringTask;
Console.Write(msg);
}
The above is then called in a Step Function
public async Task<State> TriggerInitiationEventAsync(State state, ILambdaContext context)
{
state.Message = "TriggerInitiationEvent";
if (!string.IsNullOrEmpty(state.Name))
{
state.Message += " " + state.Name;
}
string fileName = "json_templates/Initiation_template.json";
Console.WriteLine(File.ReadAllText(fileName));
state.Message = File.ReadAllText(fileName);
**HttpStatusCode response = await SendEventToTopic(state.Message);**
state.Message += "responseCode:" + response;
return state;
}
Appreciate the support.
Cheers
Kris