Answered in
http://stackoverflow.com/questions/27790590/modifying-server-response-payload-json

Thanks.



Mahendran Pirinthapan
Software Engineer | WSO2 Inc.
Mobile +94772378732.

On Tue, Jan 6, 2015 at 10:33 AM, Shiva Balachandran <[email protected]> wrote:

> Hi Maz,
>
> Are you sure the value of the expression in
>
>  <args>
>
>       <arg evaluator="json" expression="$.origin"/>
>  </args>
>
> is correct? I think it should be " expression="$.ipAddress" ". Also try
> initially using "ipAddress" instead of "IP Address" in the above given
> context.
>
> Thank you.
>
> Regards
> Shiva Balachandran
>
> On Tue, Jan 6, 2015 at 7:09 AM, Maz Lakadia <[email protected]> wrote:
>
>> I'm modifying a response sent by a server. To do this I've set up a test
>> API that is meant to just send back the IP, in a format like this:
>>
>> {
>>   "origin": "202.37.75.130"
>> }
>>
>> My unmodified code gives me back what I want.
>>
>> What I wish to do as a test is to change the name of "origin" to "IP
>> Address", hopefully getting a response like this:
>>
>> {
>>   "IP Address": "202.37.75.130"
>> }
>>
>> To do this I've modified my outSequence section of the code, to be this
>> (all I've added is the PayloadFactoryMediator section, the filter was there
>> before):
>>
>>
>> <outSequence>
>>   <payloadFactory media-type="json">
>>     <format>{
>>       "IP Address" : {
>>       "$1"
>>       }
>>       }
>>     </format>
>>     <args>
>>       <arg evaluator="json" expression="$.origin"/>
>>     </args>
>>   </payloadFactory>
>>   <filter source="get-property('CORS_ORIGIN')" regex=".+">
>>     <then>
>>       <property name="Access-Control-Allow-Origin" 
>> expression="get-property('CORS_ORIGIN')" scope="transport"/>
>>       <property name="Access-Control-Expose-Headers" 
>> value="Assertion,X-Jwt-Assertion,X-User-Name,X-User-Domain" 
>> scope="transport"/>
>>     </then>
>>   </filter>
>>   <send/>
>> </outSequence>
>>
>> However, when I curl to the API as before I get a response:
>>
>> curl: (52) Empty reply from server
>>
>> Can anybody tell me what I may have done wrong?
>>
>>
>> Thanks,
>> Maz
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Shiva Balachandran
> Software Engineer
> WSO2 Inc.
>
> Mobile - +94 774445788
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to