Hi I have a current payload in APIM, which I want to transform into another payload.
Current Payload:
{
"insurance_id": "2112",
"insurer_info": {
"first": "Tony",
"last": "Stark"
}
}
Expected Payload
{
"id": "2112",
"insurer_name": {
"fullname": "Tony Stark"
}
}
Attempt of the code:
<policies>
<inbound>
<base />
<return-response>
<set-status code="200" reason="ok" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
var body = context.Request.Body.As<JObject>(true);
var transformedBody = new JObject();
transformedBody["id"] = body["insurance_id"];
var insurerName= new JObject();
dependentee["fullname"] = body["insurer_info"]["first"]["last"];
transformedBody["insurerName"] = insurerName;
return transformedBody.ToString();
}</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
What I am trying to achieve is that I want to extract first and last name from the current payload. And show as full name as shown in the expected payload. What I have implemented above is wrong, and I dont understand how I can go about combining values.