JIRA upgrade & Jira rest api

Hello - we are currently looking at upgrading from Jira 6.3.12 to Jira 7.4.2. Currently we have written some custom code that accesses the Jira rest apis.

As far as I can see - looking through the documentation - there should be no affect on the api's we are calling - currently the CreateIssue api - POST /rest/api/2/issue . Please see below for the code:-

/* these variables are hardcoded for this example, in ION most are passed in from the user interface */ String jiraHost = "http://jira.fsi:8080/"
String jiraProject = "IURI";
String messageWithVersion = "ION Version 1.0.38.2807: ION is not saving my research"; String summ = "<p> ION is not saving my research, see below. <br /> <img src='/api/file/12232' ></img> </p>"
String uname = "Daniel.shaw@firststateinvestments.com";
String issueType = "Bug";
Uri address = new Uri(JiraHost + "rest/api/2/issue"); dynamic remoteMessage = new
{
fields = new
{
project = new { key = jiraProject },
summary = summ,
description = messageWithVersion,
issuetype = new { name = issueType },
customfield_10000 = uname
}
};

String json = Newtonsoft.Json.JsonConvert.SerializeObject(remoteMessage);
byte[] byteData = UTF8Encoding.UTF8.GetBytes(json);
HttpWebRequest JIRARequest = WebRequest.Create(address) as HttpWebRequest;
// Set type to POST 
JIRARequest.Method = "POST";

// Set the content length in the request headers 
JIRARequest.ContentLength = byteData.Length;
JIRARequest.ContentType = "application/json";

/* code block for the GetEncodedCredentials function below private string GetEncodedCredentials()
{
string mergedCredentials = string.Format("{0}:{1}", "ionuser", "F1rststate");
byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
return Convert.ToBase64String(byteCredentials);
}
*/
string base64Credentials = GetEncodedCredentials();

JIRARequest.Headers.Add("Authorization", "Basic " + base64Credentials);
// Write data 
using (Stream postStream = JIRARequest.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}

try
{
HttpWebResponse response = JIRARequest.GetResponse() as HttpWebResponse;
// Get the response stream 
StreamReader reader = new StreamReader(response.GetResponseStream());
string resString = reader.ReadToEnd();
log.DebugFormat("Response Received for JSON POST: {0}", resString);

//.... [Bunch of irrelavent stuff]

catch (Exception ex)
{
log.Error("Error Posting JIRA ", ex);
return;
}

1 answer

1 accepted

0 vote
Warren Levy Community Champion Sep 19, 2017

Hi Colin

You never actually asked a question, but i'm assuming it is whether the REST API code you've got will still work after upgrading Jira?

If so, the answer would be yes. Generally APIs would be compatible going forward in releases, so you shouldn't have any problem with it. 

See the API documentation here for the latest Server version. Near the top there is a link to all other versions as well, but the latest version still has api/2/issue so I don't foresee any issues

Thanks Warren - yes that was my question.  I had looked at that documentation, so was hoping it would be okay.  Thanks for your informative and prompt reply

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

246 views 1 18
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