简体   繁体   English

如何访问 WSO2 原型 rest API ZDE9B9ED78D7E2E1DCEEFFEE780E2F 中的帖子正文?

[英]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.在 WSO2 api 网关中,我想使用内联 javascript 对一些 POST 请求进行原型设计。 I am trying to figure out how to get the post body value which is going to be json.我试图弄清楚如何获得将是 json 的帖子正文值。 Its a pretty old version of WSO2 (I think v5.0).它是 WSO2 的一个相当旧的版本(我认为是 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.如果它们在查询字符串或 URI 中,则此脚本正确打印值,但似乎无法弄清楚如何获取 POST 正文。

I think, if mc.setPayloadJSON(...) works, its should also work:我认为,如果mc.setPayloadJSON(...)有效,它也应该有效:

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.我只是发现编写 spring 启动应用程序并返回数据而不是弄乱 WSO2 可怕的记录原型更容易。 I spent a day trying to figure out WSO2 prototyping vs 1 hour to make a real springboot app.我花了一天时间试图弄清楚 WSO2 原型设计与制作真正的 springboot 应用程序的 1 小时。 My advice: DONT USE WSO2 PROTOTYPING UNLESS YOU ARE RETURNING THE MOST BASIC RESPONSES.我的建议:除非您返回最基本的响应,否则不要使用 WSO2 原型制作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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