I am making a GET request to a task that exists and I get a 404 Not fund
this is the code
The baseUrl variable contains the Url of our JIRA.
httpClient.BaseAddress = new Uri(baseUrl);
var requestMessage = new HttpRequestMessage(HttpMethod.Get, "rest/api/3/issue/pijd-7");
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", basicAuth);
var response = await httpClient.SendAsync(requestMessage);
var str = await response.Content.ReadAsStringAsync();
Given that you're getting a 404, I'm assuming that your authentication is working.
The screenshot below is from the documentation.
To confirm that you have access to the issue, with Jira open in a browser window, open another tab and combine your baseURL with rest/api/3/issue/pijd-7 and confirm that it returns the issue details correctly.
Have you tried any other API calls? Try using /rest/api/3/search with no parameters, which should prove (or disprove) that all your other code is working correctly.
Finally, you could try using Postman (either the web based one or downloading it) which takes the element of your C# code out of it.
It definitely is possible to use the API with C# code, I've been doing it for years now.
Hi Warren,
Thank you very much for answering, all the tips that you tell me I had done.
I have solved the problem by changing several things in the code, this is the new code
using (var request = new HttpRequestMessage (new HttpMethod ("GET"), baseUrl + "/ rest / api / 3 / issue / 59998"))
{
request.Headers.TryAddWithoutValidation ("Accept", "application / json");
var base64authorization = Convert.ToBase64String (Encoding.ASCII.GetBytes (email + ":" + token));
request.Headers.TryAddWithoutValidation ("Authorization", $ "Basic {base64authorization}");
}
1. The last parameter of the url before had the name of the issue and I have changed it to the id
2. I have changed the header of the message.
3. The way to format the authentication string.
With these changes everything works correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.