cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass multiple parameters to webscript

Isha
Champ in-the-making
Champ in-the-making

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 ACCEPTED ANSWER

narkuss
Star Contributor
Star Contributor

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 answer in original post

4 REPLIES 4

EddieMay
World-Class Innovator
World-Class Innovator

Hi @Isha,

Would the args element work for you? 

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

Isha
Champ in-the-making
Champ in-the-making

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
Star Contributor
Star Contributor

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
Legendary Innovator
Legendary Innovator

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.