Empty Post Body in the request.content field eventhough the Json is sent in the request

Not applicable

Hello Everyone,

I am trying to send some data in a Post Method of a Proxy without a target, when I try to access the payload using response.content, I get null value.

Javascript code :

var payLoad = JSON.parse(context.getVariable("request.content"));

var Email = payLoad.Email;

var RequestIds = payLoad.RequestIds;

var IsFromCache = payLoad.IsFromCache;

Payload : {"Email":"test","RequestIds":"1","IsFromCache":"true"}

0 8 9,369
8 REPLIES 8

Hi @Pranay Aitha,

I guess you mean to say not able to read the request.content variable properly.

What I can think of is you might have placed the JS policy in Response element of the conditional flow.

Here I am attaching an example proxy with no target and a JS policy reading JSON payload from request.content.no-target-test-rev1-2017-01-30.zip

Hope this helps!

Thank you Zuber,

I am using JS Policy in the Request preflow.

still the same:(

Hi @Pranay Aitha,

Have you checked the proxy code that I have attached?

If possible could you please attach your proxy bundle here.

Hi Zuber,

I tried yours and its working, only on that proxy its not working. I copied my flow into a different proxy and it works, I am using the new proxy for that flow.

As the Proxy contains details of secure data, I am not able to update the proxy here 😞

Did you set the variable like so:

context.setVariable('request.content', yourVariable);

?

No Davis, I am trying to access this in the first step of preflow.

Not applicable

hv u enabled this property request.streaming.enabled=true ?

if so then request.content will be empty .

please remove it and give a try.

when I use the below and try to print am getting the following as output [object Object] . Not sure how you able to parse the request payload. Pls advice.

var payload = JSON.parse(context.getVariable("request.content"));

print(payload)

output of the above print is : [object Object]