简体   繁体   中英

How do I access post body in WSO2 prototype rest API javascript?

in WSO2 api gateway I want to prototype a few POST requests using inline javascript. I am trying to figure out how to get the post body value which is going to be json. Its a pretty old version of WSO2 (I think v5.0).

//URL: /a/b/{u1}/c?p1=123
mc.setProperty('CONTENT_TYPE', 'application/json');
var u1 = mc.getProperty('uri.var.u1'); 
var p1 = mc.getProperty('query.param.p1');
var postBody = mc.getProperty(???????????);
mc.setPayloadJSON('{ "data" : "' + p1 + '|||' + p2+ '"}');

This script is correctly printing the values if they are in the query string or the URI but cant seem to figure out how to get the POST body.

I think, if mc.setPayloadJSON(...) works, its should also work:

var body = mc.getPayloadJSON();

I simply found its easier to write a spring boot app and have that return data rather than mess with WSO2 horribly documented prototypes. I spent a day trying to figure out WSO2 prototyping vs 1 hour to make a real springboot app. My advice: DONT USE WSO2 PROTOTYPING UNLESS YOU ARE RETURNING THE MOST BASIC RESPONSES.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM