I canot connect to Bonita engine to start a case from asp.net, the next is the code, the last line fails, can anybody help me:
WebClient wc = new WebClient();
wc.Proxy = WebRequest.GetSystemWebProxy();
string clavesesion = wc.DownloadString("http://localhost:8080/bonita/loginservice?username=walter.bates&password=bpm&redirect=false");
wc.Headers[HttpRequestHeader.Cookie] = wc.ResponseHeaders[HttpResponseHeader.SetCookie].ToString();
wc.Headers[HttpRequestHeader.Accept] = "application/json";
wc.Headers[HttpRequestHeader.ContentType] = "application/json";
string cookie = wc.ResponseHeaders[HttpResponseHeader.SetCookie].ToString();
string carga = wc.DownloadString(âhttp://localhost:8080/bonita/API/bpm/process?s=ProcesoIniciarCaso&p=0&c=10&o=version&f=activationState=ENABLEDâ);
List<string> listOfNames = new List<string>(carga.Split(','));
string reemplazo = "[{\"id\":\"";
string processid = listOfNames[0].Replace(reemplazo,"").Replace("\"","");
var data = âoptions=processDefinitionIdâ + processid;
byte bytedata = UTF32Encoding.UTF8.GetBytes(data);
var response = wc.UploadData(âhttp://localhost:8080/bonita/API/bpm/caseâ, âPOSTâ,bytedata);
1 Like
Did you try starting a case through some json client (like âpostmanâ Chrome extension) before you do it form your ASP .NET application.
Thankâs for your response kiran, I have been trying different options for more than two days and I resolved, thankÂŽs to GOD, here is the code in asp.net:
WebClient wc = new WebClient();
wc.Proxy = WebRequest.GetSystemWebProxy();
string clavesesion = wc.DownloadString(âhttp://localhost:8080/bonita/loginservice? username=Helen.Kelly&password=bpm&redirect=falseâ);
wc.Headers[HttpRequestHeader.Cookie] = wc.ResponseHeaders[HttpResponseHeader.SetCookie].ToString();
wc.Headers[HttpRequestHeader.Accept] = âapplication/jsonâ;
wc.Headers[HttpRequestHeader.ContentType] = âapplication/jsonâ;
string cookie = wc.ResponseHeaders[HttpResponseHeader.SetCookie].ToString();
// the name of process is ProcesoIniciarCaso
string carga = wc.DownloadString(âhttp://localhost:8080/bonita/API/bpm/process?s=ProcesoIniciarCaso&p=0&c=10&o=version&f=activationState=ENABLEDâ);
// get the processid
List listOfNames = new List(carga.Split(â,â));
string reemplazo = â[{"id":"â;
string processid = listOfNames[0].Replace(reemplazo,ââ).Replace(â"â,ââ);
// serialize the request with Newtonsoft.Json package download from nuget in vs2012
var vm = new { processDefinitionId = processid };
var dataString = Newtonsoft.Json.JsonConvert.SerializeObject(vm);
// execute the request thar start the case of process ProcesoIniciarCaso
var response = wc.UploadString(âhttp://localhost:8080/bonita/API/bpm/caseâ, âPOSTâ, dataString);
I am really happy