How to update issue status/priority using Rest API?
Added by Alexander Zhuk about 13 years ago
I sended PUT http query using body (JSON string):
{
"issue":{
"description":"new description",
"status":{"name":"New","id":1},
"priority":{"name":"High","id":5}
}
}
issue description was changed, but status/priority left without changes. How to update field containing dictionary?
Replies (18)
RE: How to update issue status/priority using Rest API? - Added by Etienne Massip about 13 years ago
Try "status":"New"
?
RE: How to update issue status/priority using Rest API? - Added by Etienne Massip about 13 years ago
Or maybe "status_id":"New"
, check Rest_Issues.
RE: How to update issue status/priority using Rest API? - Added by Alexander Zhuk about 13 years ago
It doesn't work. I tried "status":"New", "status":"1", "status":1, status_id":"New", status_id":"1", status_id":1 - there are no status changes on server.
RE: How to update issue status/priority using Rest API? - Added by Keegan Simonse about 13 years ago
I'm having the same issue, but none of my fields are being updated. I am not updating the description field, but when I try to update status, assigned to, and the done ratio, nothing gets changed, but the ticket shows as recently being updated. I am using the current lines of code to update my issues, but I am thinking it is wrong:
string json =
"{"
"\"issue\":{"
"\"status\":{" +
"\"name\":\"" + cbStatus.Text + "\"" +
"}," +
"\"assigned_to\":{" +
"\"name\":\"" + cbAssignee.Text + "\"" +
"}," +
"\"done_ratio\":" + cbPDone.Text +
"}" +
"}";
string response = wc.UploadString(String.Format("http://{0}/issues/{1}.json?key={2}", m_Url, m_ticket.id, m_ApiKey), "PUT", json );
It would be great if someone had an answer to our problems
RE: How to update issue status/priority using Rest API? - Added by Robert Hailey about 13 years ago
Same issue here, but with XML; it seems like <status_id>1</status_id> should work, I must be doing something wrong....
RE: How to update issue status/priority using Rest API? - Added by Artur Smolarek almost 13 years ago
Jean-Philippe Lang wrote (on #9599):
You can change the status by setting status_id to the appropriate status id.
It does not work. Tested on Redmine 1.2.1 (both JSON & XML).
Could you please confirm?
RE: How to update issue status/priority using Rest API? - Added by Terence Mill almost 13 years ago
The rest api documenation btw is not detailed enough. Do i have to use datbase ids or can i also use functional keys, like name od tracker, name of status, name of project nae of catgory, user name, user email, ...
How do i get the internal id ?
For redmine user it is pretty unclear what ids are and how to resolve them from redmine gui.
Having same problem with 1.2.1.stable (MySQL) - Added by Anton Kovalenko almost 13 years ago
I do send the following payload, I can see that the issue was changed less than a minute ago according to the information on its page, but the status remained unchanged.
The status change I request is allowed by current workflow settings.
Request: PUT /issues/1868.json HTTP/1.1 Host: redmine.msk-kltn-test001.e5.ru Accept: */* Transfer-Encoding: chunked X-Redmine-API-Key: TheSecretKey Expect: 100-continue {"issue":{"status":{"name":"done","id":21},"notes":"closing all old issues"}}
So, what am I doing wrong? It is a bug in redmine REST API?
RE: How to update issue status/priority using Rest API? - Added by Jan Malte Gerth over 12 years ago
I run into this as well using Redmine 1.4. The documentation does not say anything about updating any fields other then notes or subject. Is this not possible?
RE: How to update issue status/priority using Rest API? - Added by Niels Drescher about 12 years ago
It's still seems to be not possible with Version 1.4.2
RE: How to update issue status/priority using Rest API? - Added by Vincent Caron about 12 years ago
Works for me with Redmine 2.0, my PUT payload is as suggested by Jean-Philippe :
{"issue": { "status_id": 1 }}
This mimics the web form fields, and is indeed confusing since the GET representation for status is quite different.
RE: How to update issue status/priority using Rest API? - Added by Sven Eisenschmidt about 12 years ago
I'm trying to achive the same. Nothing happens. The issue stays the same. Api key is valid,
request body and correct content type header is sent. Verfied via wireshark. Only the last modified date gets updated. What could be wrong?
JSON
{"issue": { "status_id": 1 }}
SQL (debug)
Started PUT "/redmine/issues/18911.json?key=API_KEY" for XXX at Tue Sep 25 15:32:28 +0200 2012 Processing by IssuesController#update as JSON Parameters: {"key"=>"API_KEY", "id"=>"18911"} (0.3ms) SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings` Setting Load (0.2ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'rest_api_enabled' LIMIT 1 Token Load (0.8ms) SELECT `tokens`.* FROM `tokens` WHERE `tokens`.`action` = 'api' AND `tokens`.`value` = 'API_KEY' LIMIT 1 User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` = 82 LIMIT 1 Current user: seisenschmidt (id=82) Issue Load (0.3ms) SELECT `issues`.* FROM `issues` WHERE `issues`.`id` = ? LIMIT 1 [["id", "18911"]] Project Load (0.2ms) SELECT `projects`.* FROM `projects` WHERE `projects`.`id` IN (76) Tracker Load (0.1ms) SELECT `trackers`.* FROM `trackers` WHERE `trackers`.`id` IN (48) IssueStatus Load (0.1ms) SELECT `issue_statuses`.* FROM `issue_statuses` WHERE `issue_statuses`.`id` IN (31) User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` IN (82) IssuePriority Load (0.1ms) SELECT `enumerations`.* FROM `enumerations` WHERE `enumerations`.`type` IN ('IssuePriority') AND `enumerations`.`id` IN (4) ORDER BY enumerations.position ASC EnabledModule Load (0.1ms) SELECT name FROM `enabled_modules` WHERE `enabled_modules`.`project_id` = 76 TimeEntryActivity Load (0.1ms) SELECT `enumerations`.* FROM `enumerations` WHERE `enumerations`.`type` IN ('TimeEntryActivity') AND `enumerations`.`is_default` = 1 ORDER BY enumerations.position ASC LIMIT 1 IssueCustomField Load (0.0ms) SELECT `custom_fields`.* FROM `custom_fields` WHERE `custom_fields`.`type` IN ('IssueCustomField') AND (is_for_all=1) ORDER BY position IssueCustomField Load (0.3ms) SELECT `custom_fields`.* FROM `custom_fields` INNER JOIN `custom_fields_projects` ON `custom_fields`.`id` = `custom_fields_projects`.`custom_field_id` WHERE `custom_fields`.`type` IN ('IssueCustomField') AND `custom_fields_projects`.`project_id` = 76 ORDER BY custom_fields.position IssueCustomField Load (0.3ms) SELECT `custom_fields`.* FROM `custom_fields` INNER JOIN `custom_fields_trackers` ON `custom_fields`.`id` = `custom_fields_trackers`.`custom_field_id` WHERE `custom_fields`.`type` IN ('IssueCustomField') AND `custom_fields_trackers`.`tracker_id` = 48 SQL (0.3ms) SELECT `custom_values`.`id` AS t0_r0, `custom_values`.`customized_type` AS t0_r1, `custom_values`.`customized_id` AS t0_r2, `custom_values`.`custom_field_id` AS t0_r3, `custom_values`.`value` AS t0_r4, `custom_fields`.`id` AS t1_r0, `custom_fields`.`type` AS t1_r1, `custom_fields`.`name` AS t1_r2, `custom_fields`.`field_format` AS t1_r3, `custom_fields`.`possible_values` AS t1_r4, `custom_fields`.`regexp` AS t1_r5, `custom_fields`.`min_length` AS t1_r6, `custom_fields`.`max_length` AS t1_r7, `custom_fields`.`is_required` AS t1_r8, `custom_fields`.`is_for_all` AS t1_r9, `custom_fields`.`is_filter` AS t1_r10, `custom_fields`.`position` AS t1_r11, `custom_fields`.`searchable` AS t1_r12, `custom_fields`.`default_value` AS t1_r13, `custom_fields`.`editable` AS t1_r14, `custom_fields`.`visible` AS t1_r15, `custom_fields`.`multiple` AS t1_r16 FROM `custom_values` LEFT OUTER JOIN `custom_fields` ON `custom_fields`.`id` = `custom_values`.`custom_field_id` WHERE `custom_values`.`customized_id` = 18911 AND `custom_values`.`customized_type` = 'Issue' ORDER BY custom_fields.position IssueStatus Load (0.2ms) SELECT `issue_statuses`.* FROM `issue_statuses` WHERE `issue_statuses`.`id` = 31 LIMIT 1 Role Load (0.2ms) SELECT `roles`.* FROM `roles` WorkflowTransition Load (0.1ms) SELECT `workflows`.* FROM `workflows` WHERE `workflows`.`type` IN ('WorkflowTransition') AND `workflows`.`old_status_id` = 31 AND (role_id IN (1,2,3,4,5,6,7,8,9,10) AND tracker_id = 48 AND ((author = 0 AND assignee = 0) OR author = 1)) IssueStatus Load (0.1ms) SELECT `issue_statuses`.* FROM `issue_statuses` WHERE `issue_statuses`.`id` IN (49) IssueRelation Load (0.1ms) SELECT `issue_relations`.* FROM `issue_relations` WHERE `issue_relations`.`issue_to_id` = 18911 SQL (0.2ms) BEGIN Issue Load (3.0ms) SELECT `issues`.* FROM `issues` WHERE `issues`.`root_id` = 18911 AND (`issues`.`lft` <= 1 AND `issues`.`rgt` >= 2) AND (`issues`.id != 18911) ORDER BY `issues`.`lft` CACHE (0.0ms) SELECT `roles`.* FROM `roles` WorkflowPermission Load (0.1ms) SELECT `workflows`.* FROM `workflows` WHERE `workflows`.`type` IN ('WorkflowPermission') AND `workflows`.`tracker_id` = 48 AND `workflows`.`role_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `workflows`.`old_status_id` = 31 (1.0ms) UPDATE `issues` SET `updated_on` = '2012-09-25 15:32:28', `lock_version` = 85 WHERE (`issues`.`id` = 18911 AND `issues`.`lock_version` = 84) (6.6ms) COMMIT Rendered text template (0.0ms) Completed 200 OK in 98ms (Views: 4.6ms | ActiveRecord: 15.3ms)
RE: How to update issue status/priority using Rest API? - Added by Etienne Massip about 12 years ago
Are you sure that the workfow is designed to allow you to make such a transition?
RE: How to update issue status/priority using Rest API? - Added by Danny Armstrong almost 12 years ago
Etienne Massip wrote:
Are you sure that the workfow is designed to allow you to make such a transition?
I too am seeing the web service return 200 while not doing what I asked, same as Sven. Does anyone have any info on this?
I have confirmed that my workflow allows this state change.
RE: How to update issue status/priority using Rest API? - Added by Eric Wang over 11 years ago
I fixed this issue by adding quote around the id number, hope it resolves your problem.
{"issue":{"status_id": "14" }}
RE: How to update issue status/priority using Rest API? - Added by Mauricio Hernández over 11 years ago
Hi everyone!
I struggled with this problem as well. It turns out that you have to modify the contentType in the request headers. Here is a sample using google script:
function modifyIssue(){
var payload = {"issue":{"status_id":"11","notes":"Desde Google"}}
var headers = {"X-Redmine-API-Key":"YOUR-API-KEY" }
payload =JSON.stringify(payload);
var options = {
"contentType": "application/json",
"headers": headers,
"method": "PUT",
"payload": payload
}
var url = "http://YOUR-INSTANCE/redmine/issues/6127.json";
var response = UrlFetchApp.fetch(url, options);
}
RE: How to update issue status/priority using Rest API? - Added by Danny Armstrong almost 11 years ago
Thank you Mauricio! Setting the content-type in the header fixed the issue for me. At least I got it solved in under a year.
RE: How to update issue status/priority using Rest API? - Added by Stephen Gaito 12 months ago
Hello, if anyone is still interested in updating the priority (instead of the status) you need a payload which contains:
{ "issue" =>
{
"priority_id" => newPriority,
}
}
Note you can only change those fields which are listed in the corresponding model.
In this case the model is contained in the file: `app/models/issue.rb`