cancel
Showing results for 
Search instead for 
Did you mean: 

start a new process

Not applicable
Hi,

I try to start a new process via the public api on a 4.2 on-premise installation.
If I send a POST request with a REST client to the URL http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes
with this body
 
{
"processDefinitionKey": "activitiAdhoc",
"businessKey": "55",
"variables": [
            {
                "name": "bpm_priority",
                "value": 1,
                "type": "d:int"
                }
        ]
}


I get this response:

{
error: {
errorKey: "Could not read content from HTTP request body: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token at [Source: java.io.BufferedReader@3ac6cf75; line: 3, column: 20] (through reference chain: org.alfresco.rest.workflow.api.model.ProcessInfo["variables"])"
statusCode: 400
briefSummary: "09310034 Could not read content from HTTP request body: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token at [Source: java.io.BufferedReader@3ac6cf75; line: 3, column: 20] (through reference chain: org.alfresco.rest.workflow.api.model.ProcessInfo["variables"])"
stackTrace: "[org.alfresco.rest.framework.jacksonextensions.JacksonHelper.constructList(JacksonHelper.java:139), org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper.extractJsonContentAsList(ResourceWebScriptHelper.java:301), org.alfresco.rest.framework.webscripts.ResourceWebScriptPost.extractObjFromJson(ResourceWebScriptPost.java:116), org.alfresco.rest.framework.webscripts.ResourceWebScriptPost.extractParams(ResourceWebScriptPost.java:58), org.alfresco.rest.framework.webscripts.AbstractResourceWebScript.execute(AbstractResourceWebScript.java:64), org.alfresco.rest.framework.webscripts.ApiWebScript.execute(ApiWebScript.java:127), org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:377), org.alfresco.rest.api.PublicApiRepositoryContainer.transactionedExecute(PublicApiRepositoryContainer.java:45), org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:529), org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:341), org.alfresco.rest.api.PublicApiRepositoryContainer.access$001(PublicApiRepositoryContainer.java:26), org.alfresco.rest.api.PublicApiRepositoryContainer$1.doWork(PublicApiRepositoryContainer.java:81), org.alfresco.repo.tenant.TenantUtil.runAsWork(TenantUtil.java:119), org.alfresco.repo.tenant.TenantUtil.runAsTenant(TenantUtil.java:88), org.alfresco.rest.api.PublicApiRepositoryContainer.executeScript(PublicApiRepositoryContainer.java:77), org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378), org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209), org.alfresco.repo.web.scripts.TenantWebScriptServlet.service(TenantWebScriptServlet.java:74), org.alfresco.rest.api.PublicApiWebScriptServlet.service(PublicApiWebScriptServlet.java:53), javax.servlet.http.HttpServlet.service(HttpServlet.java:728), org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305), org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210), org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61), org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243), org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210), org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222), org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123), org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502), org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171), org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99), org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953), org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118), org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408), org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023), org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589), org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852), java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145), java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615), java.lang.Thread.run(Thread.java:724)]"
descriptionURL: "http://developer.alfresco.com/ErrorsExplained.html#Could not read content from HTTP request body: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token at [Source: java.io.BufferedReader@3ac6cf75; line: 3, column: 20] (through reference chain: org.alfresco.rest.workflow.api.model.ProcessInfo["variables"])"
}-
}


Could anybody help solving my problem?
9 REPLIES 9

kaynezhang
World-Class Innovator
World-Class Innovator
I didn't find an webscript match you url (http://localhost:8080/alfresco/api/-default-/public/***),are you sure it is written correctly?

Not applicable
I copied the url from the chapter "Api Reference" on docs.alfresco.com. The format I used is described there. Maybe I missundeestood something.

kaynezhang
World-Class Innovator
World-Class Innovator
open your web browser and visit http://localhost:8080/alfresco/service/index/package/org/alfresco/repository/workflow,all webscripts related to workflow are listed here.you can see their descriptions and matching uri.

Not applicable
hi kaynezhang,

yes you are right, the WebScript I try to call is not listed at http://localhost:8080/alfresco/service/index/package/org/alfresco/repository/workflow. However the script is described in the Alfresco One Public API Reference and the fact that a GET call on the script http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes delivers a reasonable response let me assume that the script is there.

Hence I think my POST body has a bug. Could anybody help me creating a process via the public api?

boriskr
Champ in-the-making
Champ in-the-making
Hello! I've also stucked with a process launch. I do everything according to the reference:
http://docs.alfresco.com/community/pra/1/concepts/act-processes-post-process.html

It works fine if no variables are passed:

{ "processDefinitionKey":"approvingProcess" }


And when I pass some variables,

{ "processDefinitionKey":"approvingProcess",
"variables": [
    { "name":"department",
      "value":"Trades"}]
}

I get an error
"Could not read content from HTTP request body: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token\n at [Source: java.io.BufferedReader@1be281f9; line: 1, column: 44] …and so on…
What can be the cause?

sebdavid
Champ in-the-making
Champ in-the-making
Hi,

I'm facing this too with 5.0.d. It seems it is a jackson deserialization issue.

From what I see, the Json value of "variables" that we pass is an array of serialized Variable object.
But in the ProcessInfo object, the expected type for "variables" is a Map<String, Object>.
Jackson is then saying a kind of "I can't deserialize a map from a START_ARRAY token".

Sebastien.

sebdavid
Champ in-the-making
Champ in-the-making
Hi,

It seems that the documentation behind the link following link is wrong :
http://docs.alfresco.com/community/pra/1/concepts/act-processes-post-process.html

The JSon representation of a simple map (Map&lt;String, String>) is like :
{
"key1" : "value1",
"key2" : "value2",

}


As said previously, the target type of the <i>variables</i> attribute is Map&lt;String, Object>.

So I managed to start a workflow with the following request :


POST http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/processes?alf_ticket={{ALF_T...}}
Request body :
{
   "processDefinitionId": "activitiAdhoc:1:4",
   "processDefinitionKey": "activitiAdhoc",
   "businessKey": "myBusinessKey",
   "variables": {
          "bpm_assignee" : "myUserId"
   },
   "items": []   
}

jm_pascal
Star Contributor
Star Contributor
Aloah,

This is an example :

<b>POST : http://hostnameSmiley Tongueort/alfresco/api/-default-/public/workflow/versions/1/processes</b>


{
   "processDefinitionId":"activitiAdhoc:1:4",
   "variables":{
      "bpm_assignee":"admin",
      "bpm_workflowDescription":"Title Of Task",
      "bpm_sendEMailNotifications":false,
      "bpm_workflowPriority":1,
      "bpm_workflowDueDate":"2015-04-21T00:00-0400"
   },
   "items":[
      "a7049303-e538-4df0-b62e-8684bf26047d"
   ]
}


Hope it helps.

arak
Confirmed Champ
Confirmed Champ
Thanks for this information, right at this moment I needed start a workflow using the RESTful API Alfresco.

Greetings,
Pablo.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.