I just tested the following VP endpoint:
function myAttempt(request, session, config) {
newRequest = {
"Method": "POST",
"Body": request.Body,
"Domain": "https://httpbin.org/post",
};
response = TykMakeHttpRequest(JSON.stringify(newRequest));
usableResponse = JSON.parse(response);
var responseObject = {
Body: usableResponse.Body,
Code: usableResponse.Code,
Headers: {}
}
for (var k in usableResponse.Headers) {
if (usableResponse.Headers.hasOwnProperty(k)) {
responseObject.Headers[k] = usableResponse.Headers[k][0]
}
}
return TykJsResponse(responseObject, {})
}
With the following command:
curl -X POST https://<dashboard>/myapi -H "Content-Type: application/json" --data "{\"Status\":\"Ok\"}"
And httpbin returns the following:
{
"args": {},
"data": "{\"Status\":\"Ok\"}",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip",
"Auth-Sig": "Signature keyId=\"asd\",algorithm=\"hmac-sha256\",headers=\"(request-target) accept x-real-ip x-scheme content-length content-type user-agent x-forwarded-for x-forwarded-port x-forwarded-proto connection authorization date\",signature=\"I7L8J1M0W325ku0U4iQ%2BoJEhFPWr7YY6A4uFMihvwts%3D\"",
"Authorization": "Signature",
"Content-Length": "15",
"Content-Type": "application/json",
"Date": "Tue, 11 Feb 2020 13:45:37 UTC",
"Host": "httpbin.org",
"User-Agent": "curl/7.54.0",
"X-Amzn-Trace-Id": "Root=1-5e42b001-b3bbd1ba7e8612a4f2b1955a",
"X-Scheme": "https"
},
"json": {
"Status": "Ok"
},
"method": "POST",
"origin": "93.185.27.194, 93.185.27.194, 18.223.195.89, 172.31.25.233, 13.59.220.123",
"url": "http://httpbin.org/anything"
}
However if i do not send Content-Type header, it gets interpreted as a string.
So maybe this is the same issue you have: try adding content-type header set to application/json.