public JsonResult Index(JiraDeveloper newdeveloper, string[] roles) { var errors = string.Empty; var client = new RestClient(jiraUrl) { Authenticator = new HttpBasicAuthenticator("*****@*****.**", "ttMLC4eg") }; var request = new RestRequest("user", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(newdeveloper); var resp = client.Execute(request); errors += AnalyzeResponse(resp); //adding roles if ((roles != null) && newdeveloper != null) { foreach (var role in roles) { errors += AddUserToJiraGroup(newdeveloper, role, client); } } if (errors == string.Empty) { return(Json(new { Message = "User successfully added." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Data = errors }, JsonRequestBehavior.AllowGet)); } }
public string AddUserToJiraGroup(JiraDeveloper newdeveloper, string role, IRestClient client) { var requestBody = string.Format("group/user?groupname={0}", role); var request = new RestRequest(requestBody, Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(new { name = newdeveloper.name }); var resp = client.Execute(request); return(AnalyzeResponse(resp)); }