【发布时间】:2014-12-02 06:17:32
【问题描述】:
我尝试执行一个包含多个参数的 POST 请求。一个参数需要一个 JSON 文件。我尝试了几个选项,但我面临 json 的问题。需要json的参数是'swagger'..
这是我尝试的 curl 请求。[1]但看起来这不被服务器接受。我收到以下错误;
"null is not supported"}curl: (6) Could not resolve host: swaggerimpl.json
如何使用 curl 为特定参数发布 JSON?
[1]
curl -X POST -b cookies $SERVER/publisher/site/blocks/item-design/ajax/add.jag -d "action=implement&name=YoutubeFeeds&visibility=public&version=1.0.0&provider=admin&endpoint_type=http&implementation_methods=http&wsdl=&wadl=&endpointType=nonsecured&production_endpoints=http://gdata.youtube.com/feeds/api/standardfeeds&implementation_methods=endpoint" -H 'Content-Type: application/json' -d 'swagger=' @swaggerimpl.json
编辑:
卷曲命令
curl -X POST -b cookies $SERVER/publisher/site/blocks/item-design/ajax/add.jag -d "action=implement&name=YoutubeFeeds&visibility=public&version=1.0.0&provider=admin&endpoint_type=http&implementation_methods=http&wsdl=&wadl=&endpointType=nonsecured&production_endpoints=http://gdata.youtube.com/feeds/api/standardfeeds&implementation_methods=endpoint" -d @swagger_impl.json -d @endpointconfig_impl.json;
错误; 在 java.lang.Thread.run(Thread.java:695) 原因:java.lang.ClassCastException:org.mozilla.javascript.NativeJavaArray 不能转换为 java.lang.String 在 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
可疑的 json 文件
swagger={
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"authorizations": {
"oauth2": {
"scopes": [],
"type": "oauth2"
}
},
.........
}
演员代码:
public static boolean jsFunction_updateAPIImplementation(Context cx, Scriptable thisObj,
Object[] args, Function funObj) throws Exception, ScriptException {
boolean success = false;
if (args==null||args.length == 0) {
handleException("Invalid number of input parameters.");
}
NativeObject apiData = (NativeObject) args[0]; //This cause issue
【问题讨论】: