Hi,
I’m trying to start a case with REST API (RestSharp) from an asp Website but I have an exception that I don’t really understand.
This is my code :
req = new RestRequest("loginservice", Method.POST);
req.AddParameter("username", tbx_username.Text);
req.AddParameter("password", tbx_password.Text);
req.AddParameter("redirect", "false");
response = client.Execute(req);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
if (response.Cookies.Count == 1)
{
Session["Cookie"] = response.Cookies[0];
Session["Role"] = 0;
Session["Username"] = tbx_username.Text;
//Instanciation d'un workflow
object json = new
{
processDefinitionId = 0
};
JsonConvert.SerializeObject(json);
req = new RestRequest("API/bpm/case/", Method.POST);
req.AddCookie(response.Cookies[0].Name, response.Cookies[0].Value);
req.AddHeader("Content-Type", "application/json");
req.RequestFormat = DataFormat.Json;
req.AddBody(json);
}
}
The connexion works perfectly, I get the cookie and give it to the request.
Anyone can help me ?
This is my exception :
{“exception”:“class java.lang.NullPointerException”,“message”:“”,“stacktrace”:[“org.bonitasoft.web.rest.server.datastore.bpm.cases.CaseSarter.(CaseSarter.java:50)”,“org.bonitasoft.web.rest.server.datastore.bpm.cases.CaseDatastore.add(CaseDatastore.java:143)”,“org.bonitasoft.web.rest.server.api.bpm.cases.APICase.add(APICase.java:51)”,“org.bonitasoft.web.rest.server.api.bpm.cases.APICase.add(APICase.java:42)”,“org.bonitasoft.web.rest.server.framework.API.runAdd(API.java:157)”,“org.bonitasoft.web.rest.server.framework.APIServletCall.doPost(APIServletCall.java:188)”,“org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.doPost(ToolkitHttpServlet.java:188)”,“javax.servlet.http.HttpServlet.service(HttpServlet.java:643)”,“org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:75)”,“javax.servlet.http.HttpServlet.service(HttpServlet.java:723)”,“org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:226)”,“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.AbstractAuthorizationFilter.doFilter(AbstractAuthorizationFilter.java:60)”,“org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)”,“org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)”,“org.bonitasoft.console.common.server.login.filter.AbstractAuthorizationFilter.doFilter(AbstractAuthorizationFilter.java:60)”,“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)”]}
Cheers