Hi,
I have an API on Apigee that sets the content type of the request that is sent in JSON format to vnd.kafka.json.v2+json and then it converts the payload of the request to the desired format before sending it to Kafka (https://docs.confluent.io/platform/current/kafka-rest/api.html#crest_v2_api). In Apigee it seems to be simple, you have just to do that:
<Set>
<Headers>
<Header name="Content-Type">
application/vnd.kafka.json.v2+json
</Header>
<Header name="Authorization">Bearer {output_jwt}</Header>
</Headers>
<Payload name="request.content">{
"records": [
{
"value": {request.content}
}
]
}
</Payload>
</Set>
I need to migrate the same API to API Management on Azure, but I couldn't get it working yet. I'm trying to do the same using set-body, but I got error 500 (Internal Server Error), because the JSON generated is not valid. I've tried in several ways like these below but it didn't work.
1)
<set-header name="Content-type" exists-action="override"><value>application/vnd.kafka.json.v2+json</value></set-header>
<set-body>{ "records": [{ "value": {context.Request}}]}</set-body>
2)
<set-header name="Content-type" exists-action="override"><value>application/vnd.kafka.json.v2+json</value></set-header>
<set-variable name="payload" value="@(context.Request.Body.As<JObject>())" />
<set-body>{ "records": [{ "value": context.Variables["payload"]}]}</set-body>
Could you help me with this please? It can be using approach above, if possible, or any other that works.
Thanks in advance.
Best Regards
