Hi,
I want to set a variable of my bonita process throught c# code using restApi (RestSharp). And I can’t find a way to serialize the request payload to add in the body of the request.
string o = convert.Serialize("{id:\"" + processId.ToString() + "/stringToReplace\",name:\"stringToReplace\",type:\"java.lang.String\",value:\"testBonita\"}");
req = new RestRequest("API/bpm/caseVariable/"+ processId.ToString()+"/stringToReplace", Method.PUT);
req.AddCookie(cookieLogin.Name, cookieLogin.Value);
req.AddHeader("Content-Type", "application/json");
req.RequestFormat = DataFormat.Json;
req.JsonSerializer = new CustomConverter { ContentType = "application/json" };
req.AddBody(o);
response = client.Execute(req);
The variable response always have StatusCode to InternalServerError with the error :
{"exception":"class java.lang.ClassCastException","message":"org.bonitasoft.web.toolkit.client.common.TreeLeaf cannot be cast to org.bonitasoft.web.toolkit.client.common.TreeIndexed","stacktrace":["org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:188)","org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:168)","org.bonitasoft.web.rest.server.framework.APIServletCall.getJSonStreamAsItem(APIServletCall.java:84)","org.bonitasoft.web.rest.server.framework.APIServletCall.doPut(APIServletCall.java:198)","org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.doPut(ToolkitHttpServlet.java:189)","javax.servlet.http.HttpServlet.service(HttpServlet.java:646)","org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:71)","javax.servlet.http.HttpServlet.service(HttpServlet.java:723)","org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:222)","org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)","org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)","org.bonitasoft.console.common.server.login.filter.FilterManager.pageRedirect(FilterManager.java:88)","org.bonitasoft.console.common.server.login.filter.FilterManager.doFilter(FilterManager.java:68)","org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)","org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)","org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)","org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)","org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)","org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)","org.bonitasoft.console.security.SessionFixationValve.invoke(SessionFixationValve.java:77)","org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)","org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)","org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)","org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)","org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)","java.lang.Thread.run(Thread.java:744)"]}
So I think my serialize is bad. Someboby can explain me how to serialize this request payload and what kind of parameter need the serializer ?
Cheers.