I've been trying to figure this out for several days, trying every possible combination of JSON string I could find, still will not work. I am trying to create a new issue in my service desk project, I keep getting:
" System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.
at System.Net.HttpWebRequest.GetResponse() "
My authentication is working fine, it just seems like I can't create an issue., my guess is a malformed json string format but I have literally copied/pasted many solutions (changing the project key ofcourse) and it's not working. What am I doing wrong?
I am using visual studio with C# with Jira Cloud instance
string stringData = @{"fields"": {""project"":{""key"": ""KEYHERE""},""summary"": ""REST ye merry gentlemen."",""description"": ""Creating of an issue using project keys and issue type names using the REST API"",""issuetype"": {""name"": ""Ticket""}}}";
string url = @"http://HOST.atlassian.net/rest/api/2/issue";
var data = Encoding.ASCII.GetBytes(stringData); // or UTF8
WebRequest wrUrl = WebRequest.Create(url);
wrUrl.ContentType = "application/json";
wrUrl.Method = "POST";
wrUrl.Headers["Authorization"] = "Basic " + Convert
.ToBase64String(Encoding.ASCII.GetBytes(SharepointUsername+":"+JiraAPIString));
wrUrl.ContentLength = data.Length;
var newStream = wrUrl.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
Stream stream = wrUrl.GetResponse().GetResponseStream();