@Suresh Thakur, Kirti APIM does support C# 7 in the policy expression. You can refer to API Management Policy Expressions documents for more details on .NET Framework types allowed in policy expressions.
Input Body:
--newreq
GET Abc?$format=json HTTP/1.1
--newreq
GET Abc?$format=json HTTP/1.1
--endreq--
Policy Expression:
<set-body>@{
string inBody = context.Request.Body.As<string>(preserveContent: true);
string[] textSplit = Regex.Split(inBody, "--newreq");
string newString = String.Empty;
string strpostBody = "Content-Type:" + "application/http" + "\n" + "Accept:" + "application/json";
for(int i=0; i < textSplit.Length-1;i++)
{
newString += "--newreq \n" + strpostBody + textSplit[i+1];
}
return newString;
}</set-body>
The below body is set:
--newreq
Content-Type:application/http
Accept:application/json
GET Abc?$format=json HTTP/1.1
--newreq
Content-Type:application/http
Accept:application/json
GET Abc?$format=json HTTP/1.1
--endreq--
You can modify the c# expression as per your need and test different use cases. Feel free to get back to me if you need any assistance.