I want to put json payload in request of proxy and filter it out in response

i want to have the following json data in request

{"altitude":"444.0","heading":"230.0","timestamplocal":"2018-12-07 18:37:24","fuelLevel":"359.04"

How can i put the data in request of proxy?

0 7 273
7 REPLIES 7

The above json payload in request.I want to filter out only 2 keys in the response.Can u explain the flow also?What will be my target backend for the above project?

@himadri bhattacharjee, can you explain a little bit more. Is this payload coming in the request to the API proxy or do you want to have this as a static payload sent to the Target? Which keys do you want to filter and what is the response json format you are expecting?

Wherever you would be routing your request that would be your target backend. Or are you using the API proxy just to manipulate the request json and send out the response?

You can use the extract variables policy with the jsonpath to filter out the required json elements

I want to create a request to input into api proxy.

the keys i want are vehicleregnumber,latitude,longitude,gpsspeed.

Do you have the swagger or sample request payload?

If you are free to decide the request payload structure, you can have a flat structure with the attributes mentioned by you.

{"altitude":"444.0","heading":"230.0","timestamplocal":"2018-12-07 18:37:24","fuelLevel":"359.04","location":"Srinagar - Kanyakumari Hwy, Naduhalli, Tamil Nadu 636701, India","vehicleregnumber":"NL01AA3961",

Please guide me how can i set up the request?

You can add Extract variables policy to get the vehicle number from the request payload as below. The value can then be set in the response be referencing the variable {vehicleNum}

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1"> <DisplayName>Extract JSON data</DisplayName> <Properties/> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="vehicleNum"> <JSONPath>{vehicleregnumber}</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">request</Source> <VariablePrefix></VariablePrefix> </ExtractVariables>

To get the latitude and longitude using the zip code, you can use google geocoding service, refere here - https://community.apigee.com/questions/1651/how-to-get-longitude-and-latitude-of-a-location-us.html

Your request is not clear.

What do you mean "I want to HAVE THE FOLLOWING DATA"?

Are you asking about how to structure your client code to make a request containing that data?

"Putting the data in the request" is ... dependent upon the client framework you use. If you use curl, then you can "PUT" the data in the request by using the -d switch.

curl -i https://myendpoint/mybasepath -H content-type:application/json \
  -d '{"altitude":"444.0","heading":"230.0","timestamplocal":"2018-12-07 18:37:24","fuelLevel":"359.04"}'

If I do this, then the thing (maybe a proxy) listening at https://myendpoint/mybasepath will receive that data.

If this is NOT what you want to do, then you'll need to be much more descriptive and specific about what you are asking. Give examples. Elaborate.