1
votes

I'm trying to change status in jira using c# by put method. in the rest API documentation I've saw that i need to connect like this: /rest/api/3/workflow/transitions/{transitionId}/properties' but i i'm not sure of what parameters to change in the line. how do i find the transition id.. or should i change the word properties with some property..
i'm a fresh student so be Gentle with me.

I have searched all over the web and also tried to ask one of my teachers and a fellow programmer. this is the code i have written/copied from the web:

Jira jira = Jira.CreateRestClient("http://localhost:8080/", "username", "password);
HttpWebRequest request = WebRequest.Create("http://localhost:8080/") as HttpWebRequest;
request.ContentType = "application/json";
request.Method = "GET";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

var projectKey = "CLEARN";

string base64Credentials = GetEncodedCredentials();
var client = new RestClient("http://localhost:8080/rest/api/3/workflow/transitions/{transitionId}/properties' ");
var request2 = new RestRequest(Method.PUT);
request2.AddHeader("postman-token", "BL0C-B43C-1ZWZ-NQUW_68b5a15fbd28c0a42df2cb47e8f7831155704df9");
request2.AddHeader("cache-control", "no-cache");
request2.AddHeader("Authorization", "Basic " + base64Credentials);
request2.AddHeader("content-type", "application/json");
request2.AddParameter("application/json", "\r\n{\r\n \"update\": {},\r\n \"transition\": {\r\n \"id\": \"10000\"\r\n },\r\n \"fields\": {\r\n \"resolution\": {\r\n \"name\": \"Done\"\r\n }\r\n }\r\n}", ParameterType.RequestBody);


IRestResponse response2 = client.Execute(request2);

for now i get forbidden status code when i'm trying to change values in the url.

1

1 Answers

0
votes

this the correct code that made the correct change:

" string base64Credentials = GetEncodedCredentials(); var client = new RestClient("http://localhost:8080/rest/api/2/issue/clearn-1/transitions/"); var request2 = new RestRequest(Method.POST); request2.AddHeader("postman-token", "2f8d5f8e-c7a2-4dd6-acc3-2f992f244455"); request2.AddHeader("cache-control", "no-cache"); request2.AddHeader("Authorization", "Basic " + base64Credentials); request2.AddHeader("content-type", "application/json"); request2.AddParameter("application/json", "\r\n{\r\n \"update\": {},\r\n \"transition\": {\r\n \"id\": \"41\"\r\n }}", ParameterType.RequestBody); "