How to post a json for a particular parameter using CURL -


i try post request contains number of parameters. 1 parameetr require json file. tried several options face issue json. parameter requires json 'swagger'.. here curl request try.[1] looks not accepted server. im getting following error;

"null not supported"}curl: (6) not resolve host: swaggerimpl.json 

how can post json using curl particular parameter?

[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  

edit :

curl command

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; 

error; @ java.lang.thread.run(thread.java:695) caused by: java.lang.classcastexception: org.mozilla.javascript.nativejavaarray cannot cast java.lang.string @ @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39)

the suspect json file

swagger={     "apiversion": "1.0.0",     "swaggerversion": "1.2",     "authorizations": {         "oauth2": {             "scopes": [],             "type": "oauth2"         }     }, ......... } 

the cast code:

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 

parameter adding @ end should not contain space. if remove space '@swagger.json' added test (not file content). if want pass json parameter can add file parameter name like: swagger={..}

it looks workaround curl merge every -d parameter request parameters , doesn't allow unquoted spaces.


Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -