Junos Space Developer
Reply
Contributor
satish.mane@techmahindra.com
Posts: 54
Registered: ‎07-26-2011
0

script management api not working in Junos Space 11.2

[ Edited ]

Hi,

I am trying to execute a script on a device using Junos rest api "/api/space/script-management/scripts/exec-deploy".

For this I created a queue as this is a asynchronus call. My JSON input for this is as below:

 

{"exec-deply":[{"scriptMgmt":   {"script":{"@href":"/api/space/script-management/scripts/2129949"},  "scriptVersionSelected":"1.1",  "device":{"@href":"/api/space/device-management/devices/1015815"},   "scriptParams":   [{"scriptParam":   {"paramName":"test",    "paramValue":"test"} }]  }}]}

 

Script Id and Device Id already exists in the system. When I try to execute POST request on this API, I get message as below:

 

message javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"exec-deploy"). Expected elements are <{}scriptMgmt>,<{}scriptMgmts>,<{}scriptParam>

description The request sent by the client was syntactically incorrect (javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"exec-deploy"). Expected elements are <{}scriptMgmt>,<{}scriptMgmts>,<{}scriptParam>).

 

It seems the request parameter has some problems. I used the JSON input as per given in Junos Space SDK help.

Please help to resolve this issue.

 

Thanks

 

 

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: script management api not working in Junos Space 11.2

Hi Satish,

 

     We recommend using Space SDK 11.3 version.  Can you please test the same and let me know are you still facing the issue.

 

 

 

Regards,

 

Vimala.

Contributor
satish.mane@techmahindra.com
Posts: 54
Registered: ‎07-26-2011
0

Re: script management api not working in Junos Space 11.2

Hi Vimala,

 

I tried this using Junos Space 11.3 also, but I am getting the same error.

 

Thanks,

Satish

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: script management api not working in Junos Space 11.2

Hi Satish,

 

    There is spell error in your input which you have specified. You have given "exec-deply" it should be "exec-deploy".

 

 

{"exec-deploy":[{"scriptMgmt":  
 {"script":{"@href":"/api/space/script-management/scripts/458752"},
 "scriptVersionSelected":"1.1",  "device":{"@href":"/api/space/device-management/devices/491544"},
  "scriptParams":   [{"scriptParam":{"paramName":"test","paramValue":"test"} }]  }}]}

 

 

 

Regards,

 

Vimala.

 

 

Contributor
satish.mane@techmahindra.com
Posts: 54
Registered: ‎07-26-2011
0

Re: script management api not working in Junos Space 11.2

Hi Vimala,

I checked my script again, and there is no mistake in script. There might be typo error while putting it in forum.

My script contents are :

 

{"exec-deploy":[{"scriptMgmt":{"script":{"@href":"/api/space/script-management/scripts/2916368"}, "scriptVersionSelected":"1.1", "device":{"@href":"/api/space/device-management/devices/1015809"}, "scriptParams":[{"scriptParam":{"paramName":"test", "paramValue":"test"}}]}}]}

 

Here is the full log:

 

 configureRouter- Base URL of the Server http://10.5.11.160:8080
2011-12-15 07:13:00,985 DEBUG [vnd.techmjunosteam.vpnconfigurations.rest.v1.VPNConfigurationsRestImpl] (http-0.0.0.0-8080-26:smileyhappy: configureRouter - script content {"exec-deploy":[{"scriptMgmt":{"script":{"@href":"/api/space/script-management/scripts/2916368"}, "scriptVersionSelected":"1.1", "device":{"@href":"/api/space/device-management/devices/1015809"}, "scriptParams":[{"scriptParam":{"paramName":"test", "paramValue":"test"}}]}}]}
2011-12-15 07:13:01,040 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] (http-0.0.0.0-8080-4:smileyhappy: Failed executing POST /scripts/exec-deploy
org.jboss.resteasy.plugins.providers.jaxb.JAXBUnmarshalException: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"exec-deploy"). Expected elements are <{}scriptMgmt>,<{}scriptMgmts>,<{}scriptParam>]
        at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.readFrom(AbstractJAXBProvider.java:86)
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105)
        at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:46)
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108)
        at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:111)
        at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:93)
        at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:146)
        at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:114)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)
        at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:252)
        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:217)
        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:206)
        at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:207)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
        at org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn.invoke(ClusteredSingleSignOn.java:638)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
        at java.lang.Thread.run(Thread.java:619)

 

Thanks,

Satish

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: script management api not working in Junos Space 11.2

Hi Satish,

 

Send me the complete details. 1) REST URL passed 2) Input passed 3) HTTP Method 4) content-type sepecified.

 

Regards, Vimala.

Contributor
satish.mane@techmahindra.com
Posts: 54
Registered: ‎07-26-2011
0

Re: script management api not working in Junos Space 11.2

Hi Vimala,

Here are the complete details

 

1) REST URL - http://10.5.11.160:8080/api/space/script-management/scripts/exec-deploy?queue=http://10.5.11.160:8080/api/hornet-q/queues/jms.queue.testq

 

2) Input Passed :

 

{"exec-deploy":[{"scriptMgmt":{"script":{"@href":"/api/space/script-management/scripts/2916368"}, "scriptVersionSelected":"1.1", "device":{"@href":"/api/space/device-management/devices/1015809"}, "scriptParams":[{"scriptParam":{"paramName":"test", "paramValue":"test"}}]}}]}

 

3) HTTP Method : POST

 

4) Content-Type: "application/vnd.net.juniper.space.script-management.exec-deploy+json;version=1"

 

 

Thanks,

Satish

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: script management api not working in Junos Space 11.2

Hi Satish,

 

     This is version 2 API and your are using version 1. Modify it to version 2 and execute. 

 

 

 

Regards,

 

Vimala.

Contributor
satish.mane@techmahindra.com
Posts: 54
Registered: ‎07-26-2011
0

Re: script management api not working in Junos Space 11.3

Hi Vimala,

 

As I am refering to API's in the eclipse help, API version for /api/space/script-management/scripts POST method is version 1 and API version for /api/space/script-management/scripts/exec-deploy POST method is version 2. If I go with this, then I get version mismatch error. Hence I used version 1 for deploy as well.

 

Thanks,

Satish

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: script management api not working in Junos Space 11.3

Hi Satish,

 

    As discussed in  the call yesteraday the input varies from version 1 to version 2.  Pl. refer to the documentation and ensure you use the exact input XML format.

 

 

 

Regards,

 

vimala.

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.