Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×
Hi,
I am trying to update a version in a project using the REST api via .NET
I can sucessfully do GETs but PUTs and POSTs fail with a '400 bad request' error
Here is the code I am using - the json string has been hard-coded (and copied from the API documentation) until I can get this to work:
var request = WebRequest.Create("http://jira-devt:8080/rest/api/2/version"); request.Method = "POST"; request.ContentType = "application/json"; var json = "{\"description\": \"An excellent version\",\"name\": \"New Version 1\",\"userReleaseDate\": \"5-Jul-2010\",\"project\": \"ADAS\",\"releaseDate\": \"2010-07-05\",\"released\": true,\"archived\": false}"; var writer = new StreamWriter(request.GetRequestStream()); writer.Write(json); writer.Close(); response = request.GetResponse();
Any ideas please?
Thanks
Mark
Here is some code (in case anyone else wants to do this sort of thing :-) ):
var json = "{\"description\": \"An excellent version\",\"name\": \"New Version 1\",\"project\": \"ADAS\",\"releaseDate\": \"2010-07-05\",\"released\": true,\"archived\": false}"; var request = WebRequest.Create("http://jira:8080/rest/api/2/version"); request.Method = "POST"; request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("admin:JiraAdminPasswordGoesInHere-OtherUsersAreAvailable..."))); // if you need to login request.ContentType = "application/json"; request.GetRequestStream().Write(Encoding.ASCII.GetBytes(json), 0, json.Length); var reader = new StreamReader(request.GetResponse().GetResponseStream()); var jsonResponse = reader.ReadToEnd(); // And if you have defined typed objects you can deserialise using the Newstonsoft.Json library ... var version = JsonConvert.DeserializeObject<Version>(jsonResponse);
Hey all,
It doesn't like both releaseDate and userReleaseDate beging specified at once!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.