Error 500 start a case from asp.NET via REST API

1
+1
-1

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=...");

    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 answer

1
0
-1

Did you try starting a case through some json client (like "postman" Chrome extension) before you do it form your ASP .NET application.

Comments

Submitted by edinsonraul on Tue, 10/25/2016 - 04:49

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=...");

// 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

Notifications