Add project through API in JIRA by .net application

Hi All
         I trying to create one project in JIRA through API by Application. Below i giving my code. I not getting any exception. But Not adding project to JIRA. Where i doing mistake?

 string url = "";
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.ContentType = "application/json";
            request.Method = "POST";
            string base64Credentials = GetEncodedCredentials();
            request.Headers.Add("Authorization", "Basic " + base64Credentials);
            request.ContentLength = data.Length;
                using (var reqStream = request.GetRequestStream())
                using (StreamWriter writer1 = new StreamWriter(reqStream))
            catch (Exception e1)
                throw e1;// error handling code

 private string GetEncodedCredentials()
            string mergedCredentials = string.Format("{0}:{1}", "username", "password");
            byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
            return Convert.ToBase64String(byteCredentials);


I reffered below url and Passing data

2 answers

Please make sure REST API option is enabled in JIRA.



How can i check that? . I getting response from API.

0 votes

You appear to be calling the create function without giving it any data.

Hi Nic Brough Thanks for your response. I passing data in same format below mentioned url. I not able to give here that format here i getting error when i click button string data= "\"fields\": { \"project\": { \"id\": \"TJI\" }, \"description\": \"Hellow why doesn't this work\", \"summary\": \"REST ye merry gentlemen.\", \"issuetype\": { \"name\": \"Bug\" } } ";

string data passing to API

The fields in there are for issue creation/update, not project. Try sending it the correct data format, as listed in the link you've given.

string data = "{\"key\": \"EX1\",\"name\": \"Example1\",\"projectTypeKey\": \"software\",\"description\": \"Example Project description\",\"url\": \"\"}" I tried this. But not working

Ok, is EX1 a valid project key in your system? What error message / response are you getting to this call?

I try to create new project with this key. I not getting any error message or response But when i debug my code below mentioned code executing using (var reqStream = request.GetRequestStream()) using (StreamWriter writer1 = new StreamWriter(reqStream)) { writer1.Write(data); }

There's always a response of some sort, unless the call works, so my best guess is that your code is not actually performing the call, or it's not processing the response. I can't help you with your .net code, I don't use it.

Are you able to say what are the possibility of non performing call?

Start by ignoring your code. On a command line, try a simple "curl" call to create the project (have a look at the example code in the docs for doing that). That will always give you a response of some sort. If it fails, you'll get an error telling you why. If it works, then you know your code is not performing the call.

How make REST API option enable in Jira ?

If you're on Server, check Admin -> General Settings -> Remote API is enabled (it is on by default) If you're on Cloud, then it's enabled.

Toady i getting error message from Jira when i try to add project. That messge i giving below StatusCode: MethodNotAllowed, Content-Type: text/html;charset=UTF-8, Content-Length: 0 whats meaning of this?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

394 views 6 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you