I have the below code to execute without datafield
Need advise to run the same task with datafield
pHttpPost, ActionName("ActionCR")]
public async Task<JsonResult> ActionCR(int CRID, string SNID, string action)
{
ChangeRequest changeRequest = await db.ChangeRequests.FindAsync(CRID);
// post XML to process service
System.Threading.Tasks.Task<HttpResponseMessage> response;
System.Net.Http.HttpClientHandler handler = new HttpClientHandler();
string K2ServerURL = @"https://k2d.asm.com/K2Services/REST.svc";
string worklistTasksEndpointURI = @"/Worklist/Items";
handler.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
{
using (HttpClient client = new HttpClient(handler))
{
string resourceAddress = worklistTasksEndpointURI;
//if you want to start sync, append ?synchronous=true to the URL;
client.BaseAddress = new Uri(K2ServerURL + "/");
string actionName = "(" + action + ")";
ViewBag.SNID = SNID;
string serialNumber = "(" + ViewBag.SNID + ")";
string completeTaskURL = K2ServerURL + worklistTasksEndpointURI + serialNumber + @"/Actions" + actionName + @"/Execute?format=JSON";
//start an async call to the service. Normally you would use more advanced threading for this approach
response = client.GetAsync(completeTaskURL);
response.Wait();
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(response.Result.StatusCode.ToString());
}
}
}
var redirectionURL = new UrlHelper(Request.RequestContext).Action("Details", "ChangeRequests", CRID);
return Json(new { ChangeRequestID = changeRequest.ChangeRequestID, Url = redirectionURL, Id = changeRequest.ID });