I'm using the following C# code to POST a version to Jira, but it returns a 403. I have other code to PUT an edit to a version with no problem, but POST errors, so I think my code is correct overall since that is working. At one point this was working perfectly, but we upgraded our jira version this year and it stopped working afterwards.
var req = (HttpWebRequest)WebRequest.Create(url);
req.Headers.Add("Authorization: Basic " + Base64Encode(Creds.GetCredString()));
req.UserAgent = UserAgentString;
req.Method = method;
req.ContentType = "application/json";
req.ContentLength = data.Length;
req.Accept = "application/json";
req.Headers.Add("X-Atlassian-Token", "nocheck");
var pdata = Encoding.ASCII.GetBytes(data);
using (var stream = req.GetRequestStream())
{
stream.Write(pdata, 0, data.Length);
}
_log.Debug($"{method}ing to {url}: {data}");
var res = req.GetResponse();
using (var strm = res.GetResponseStream())
{
StreamReader reader = new StreamReader(strm);
return reader.ReadToEnd();
} to url
http://ourdomain:8080/rest/api/2/version
My data is like
var json = $@{{
"name"": ""{name}"",
""startDate"":""{date:yyyy-MM-dd}"",
""project"":""{Settings.Project}"",
}}"; The user credentials (my login) have no problem with this on the UI. I tried to inspect the UI POST to see if i was doing anything wrong, but it matched as much as it could. This is a utility program to help us automate our version releases.
What am I doing wrong? Is there some setting for this for the uesr for API only?