How to get error response code when update was fail in PUT REST API
Added by Akira Saito almost 6 years ago
Hi,
I am trying to use PUT REST API and changing status_id in a issue.
I want to get error http response in the below situation but I got 200 OK response.
- A issue has child issues which are not completed.
(In this case, we cannot change parent issue completed status.) - When we use PUT REST API and try to change parent issue completed.
- parent issue status was not changed but http response is `200 OK`
I tested this curl command:
curl -XPUT -H "content-type: application/json" -H "X-Redmine-Api-Key: xxx" https://redminehost.com/issues/{issueid}.json -d '{"issue": {"status_id":96}}' -v
status_id:96 is completed status.
I got this http response:
> PUT /issues/{issueid}.json HTTP/2 > Host: redminehost > User-Agent: curl/7.54.0 > Accept: */* > content-type: application/json > X-Redmine-Api-Key: xxxxxxxxx > Content-Length: 27 > * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * We are completely uploaded and fine < HTTP/2 200 < date: Mon, 18 Feb 2019 00:59:52 GMT < content-type: application/json < server: nginx/1.14.1 < x-frame-options: SAMEORIGIN < x-xss-protection: 1; mode=block < x-content-type-options: nosniff < x-download-options: noopen < x-permitted-cross-domain-policies: none < referrer-policy: strict-origin-when-cross-origin < cache-control: no-cache < x-request-id: 330ce669-57c2-4e84-8387-92d5b8eab381 < x-runtime: 0.119958 < vary: Origin
Is there any way to get error response when status was not changed ?
I want to know whether status_id was changed or not by http response code.
I would be grateful if you share good way.
My Environment was below:
Environment: Redmine version 4.0.1.stable Ruby version 2.6.0-p0 (2018-12-25) [x86_64-linux] Rails version 5.2.2 Environment development Database adapter Mysql2 Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery smtp SCM: Subversion 1.9.7 Git 2.14.5 Filesystem Redmine plugins: no plugin installed
Thanks for helping :)