The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

not able to consume Create Project from c#

Harry Singh
May 10, 2017

Hello Team,

I'm trying to create project on jira from my c# code and it is not working but when i used postman to create projcet, it create the project on jira.

Please suggest me something i reach bottleneck

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Sam Hall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 10, 2017

Hi Harry - to get a decent answer, you'll need to share a bit more information here.

What are you expecting to happen and what is actually happening. Are you getting an error message? If so post the details. 

If you can share a snippet of the code you are using which shows how you are calling the API, it will help people understand what you are trying to do.

Finally, since your question is development related, consider asking it over on the dedicated developer's community: https://community.developer.atlassian.com. If you do that, post a link here so that others can follow the trail.

Harry Singh
May 12, 2017

Below is the code :-

NewProject objnewprj = new NewProject();
objnewprj.key = "TEST";
objnewprj.name = "TEST";
objnewprj.projectTypeKey = "business";
objnewprj.projectTemplateKey = "com.atlassian.jira-core-project-templates:jira-core-project-management";
objnewprj.description = "Example Project description";
objnewprj.lead = "admin";
objnewprj.url = "http://abc.co.in/";
objnewprj.assigneeType = "UNASSIGNED";
objnewprj.avatarId = 10204;
objnewprj.issueSecurityScheme = 10000;
objnewprj.permissionScheme = 10100;
objnewprj.notificationScheme = 10100;
objnewprj.categoryId = "10000";
var projectitem = new JavaScriptSerializer().Serialize(objnewprj);
byte[] formbytes = System.Text.ASCIIEncoding.Default.GetBytes(projectitem.ToString());

var webrequest = (HttpWebRequest)WebRequest.Create("http://jirademoseasia.atlassian.net/rest/api/2/project");
webrequest.Method = "POST";
webrequest.ContentType = "application/json";
webrequest.UserAgent = "xx";
try
{
var webresponse = webrequest.GetResponse();
System.IO.StreamReader reader = null;
System.IO.Stream responseStream = webresponse.GetResponseStream();
reader = new System.IO.StreamReader(responseStream);
result = reader.ReadToEnd();
}
catch(Exception ex)
{
return "error";
}
return result;

 

This implementation is working fine on Postman Software but when implementing through code giving "The remote server returned an error: (400) Bad Request." error.

One thing the url specified here is dummy and you have to provide some actual url here to run thid code.

Please review the code and give your valuable feedback.

TAGS
AUG Leaders

Atlassian Community Events