How to pass multiple parameters to webscript

cancel
Showing results for 
Search instead for 
Did you mean: 
Isha
Member II

How to pass multiple parameters to webscript

Jump to solution

Hi,

I am able to pass 2 arguments to get webscript using below code:

<webscript>
<shortname>FileFolderService Test Sample Webscript</shortname>
<description>Uses the FileFolderService to create a folder and a file</description>
<url>/sample/filefolderservicetest?partname={partname}&amp;type={type}</url>
<authentication>user</authentication>
<format default="html"></format>
<lifecycle>sample</lifecycle>
</webscript>

 

But I want to pass 29 to 30 parameters which i want to access in java conrtoller . so is there any way to pass n numbers of arguments efficiently.

 

1 Solution

Accepted Solutions
narkuss
Established Member II

Re: How to pass multiple parameters to webscript

Jump to solution

You could pass these 30 parameters as a json object in the http body, instead of using url args.

You can then retrieve them in java controller this way:

new JSONObject(req.getContent().getContent())

View solution in original post

4 Replies
EddieMay
Alfresco Employee

Re: How to pass multiple parameters to webscript

Jump to solution

Hi @Isha,

Would the args element work for you? 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
Isha
Member II

Re: How to pass multiple parameters to webscript

Jump to solution

Hi @EddieMay 

If possible can you please share one dummy code snippet  where I can get how to use args.

I have refered below url but still it requires name of all 30 arguments. Can' I pass list or array of arguments??

https://docs.alfresco.com/6.0/references/api-wsdl-args.html

Thanks

narkuss
Established Member II

Re: How to pass multiple parameters to webscript

Jump to solution

You could pass these 30 parameters as a json object in the http body, instead of using url args.

You can then retrieve them in java controller this way:

new JSONObject(req.getContent().getContent())
afaust
Master

Re: How to pass multiple parameters to webscript

Jump to solution

When you pass parameters as a JSON request body, you can use pre-parsed request objects instead of having to create a JSONObject yourself. The req.parseContent() will give you access to the request body - if in JSON, it will be JSONObject, if form-data, it will be the appropriate object for that.