How to pass an array of values to a webscript call

cancel
Showing results for 
Search instead for 
Did you mean: 
bgkoneill
Active Member

How to pass an array of values to a webscript call

Hi Guys,

I am calling a webscript (action-execution) which requires me to pass a list of params in the body of the Post.  When I try to pass an array of strings I get the below error.   Also see code below.

Therefore, what is the correct way to pass an array of strings in the body of webscript call so that they are serialised into an array or List by the webscript.

Regards

Brian

Error: {"error":{"errorKey":"Could not read content from HTTP request body: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token\n at [Source: (BufferedReader); line: 1, column: 136] (through reference chain: java.lang.Object[0]->org.alfresco.rest.api.model.Action[\"params\"]->java.util.LinkedHashMap[\"email_list\"])","statusCode":400,"briefSummary":"05190018 Could not read content from HTTP request body: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token\n at [Source: (BufferedReader); line: 1, column: 136] (through reference chain: java.lang.Object[0]->org.alfresco.rest.api.model.Action[\"params\"]-

The calling code is as follows:

let actionBodyExec = {
   "actionDefinitionId": "action.mediamonitoring.moveToAccepted",
   "targetId": mediaItem.nodeRef.substring(24),
   "params": {
      "email_list": ["brian.oneillseedim.com.au","brian.oneill@seedim.com.au"],
      "template_name": templateName,
   }
}
 this.apiService.getInstance().webScript.executeWebScript(
   'POST',
   'action-executions',
   null,
   'alfresco',
   'api/-default-/public/alfresco/versions/1',
   actionBodyExec 
   ).then((data) => {
....},
   function(error) {
      console.error(error);
   });
1 Reply
dvuika
Alfresco Employee

Re: How to pass an array of values to a webscript call

based on the error details, the server rejects your array. I suggest consulting the documentation to check if arrays are indeed supported there via REST api