Using the Jira API with C#

I am developing a .NET application to retrieve all Jira tickets from a specific project, which I’m naming ‘DevProject.’ However, when I attempt to use the Jira API, I either receive an empty response or encounter a 404 error. I suspect I might be overlooking something but I’m not exactly sure what it is.

The base URL for my company’s Jira account is ‘https://mycompany.atlassian.net,’ and I am using ‘/rest/api/3/issue/devissue’ for the REST URL. Here’s a code snippet illustrating my approach:

HttpWebResponse apiResponse = null;
HttpWebRequest apiRequest = WebRequest.Create(baseurl + restUrl) as HttpWebRequest;
apiRequest.Method = "GET";
apiRequest.Accept = "application/json";
apiRequest.ContentType = "application/json";
apirequest.Headers.Add("Authorization", "Basic " + EncodeCredentials("myUsername", "token"));

string data;
using (apiResponse = apiRequest.GetResponse() as HttpWebResponse)
{
    StreamReader streamReader = new StreamReader(apiResponse.GetResponseStream());
    data = streamReader.ReadToEnd();
}

I have also attempted using an API token in the password section, but that didn’t yield any results. I’m hoping to get back either a list of issues or any response that confirms whether I am correctly calling the API or if there is something I need to adjust. Any insights would be appreciated. Additionally, I’ve already generated an API token using my company’s Jira services.

From working with Jira’s REST API, I’ve noticed it’s crucial to ensure the correct endpoint paths are used, along with proper authentication. First, verify that ‘/rest/api/3/issue/devissue’ is indeed the correct endpoint for fetching issues by checking the official Jira API documentation. It might be that you’re meant to use ‘search?jql=project=DevProject’ instead of that specific URL path. Also, double-check that your username and token are correct and your base URL is formatted properly without extra spaces. Sometimes, network firewalls or proxies may cause issues too, so these might be worth looking into if you continue facing problems.

make sure the REST url is correct! ‘/rest/api/3/issue/devissue’ might not be right if you’re trying to list issues. try using ‘/rest/api/3/search?jql=project=DevProject’. Also, check if your token has proper permissions. Compatibility between your .NET version and the api might be a factor too.