Project

General

Profile

Getting error when updating an issue by REST API using PUT method

Added by Alexandre Mendonça Lima over 6 years ago

Hello!

I'm using Redmine REST API and I'm getting an error (500 Internal Server Error) when I'm trying to update an issue using PUT method (as recommended at wiki documentation).

I created an issue (using POST method) and Redmine set id 15833 to it.

Then I invoke http://myredmine/issues/15833.json and JSON request is:

{
  "issue": {
    "status_id": 8,
    "notes": "descritive text about the change" 
  }
}

The only answer from REST API is:

{
  "status": "500",
  "error": "Internal Server Error" 
}

My production.log don't show me what's happened and I'm getting crazy with this problem.

Please, does anyone know what's happen?


Replies (4)

RE: Getting error when updating an issue by REST API using PUT method - Added by Alexandre Mendonça Lima over 6 years ago

I can delete using DELETE method. It seems just PUT method is bugged.

My request details are:

{
  "method": "PUT",
  "transformRequest": [
    null
  ],
  "transformResponse": [
    null
  ],
  "url": "http://myredmine/issues/15836.json",
  "headers": {
    "Accept": "application/json, text/plain, */*",
    "Content-Type": "application/json;charset=utf-8",
    "X-Redmine-API-Key": "53d8db12cd55c7a0dbffb557042fa0995b25956c" 
  },
  "data": "{\n  \"issue\": {\n    \"status_id\": 8,    \"notes\": \"descritive text about the change\"\n  }\n}",
  "timeout": {}
}

RE: Getting error when updating an issue by REST API using PUT method - Added by Mayama Takeshi over 6 years ago

Hi,
I tested with your json string and could not reproduce this problem:

takeshi@takeshi-desktop:~$ curl -u ccea1c56b61c91be1f5db7faffe76f950eadf656:fake -x '' http://192.168.2.173:3000/issues/22.json -X PUT -H 'Content-Type: application/json' -d '{"issue": {"status_id": 8,"notes": "descritive text about the change" }}'
takeshi@takeshi-desktop:~$ curl -v -u ccea1c56b61c91be1f5db7faffe76f950eadf656:fake -x '' http://192.168.2.173:3000/issues/22.json -X PUT -H 'Content-Type: application/json' -d '{"issue": {"status_id": 8,"notes": "descritive text about the change" }}'
* Hostname was NOT found in DNS cache
*   Trying 192.168.2.173...
* Connected to 192.168.2.173 (192.168.2.173) port 3000 (#0)
* Server auth using Basic with user 'ccea1c56b61c91be1f5db7faffe76f950eadf656'
> PUT /issues/22.json HTTP/1.1
> Authorization: Basic Y2NlYTFjNTZiNjFjOTFiZTFmNWRiN2ZhZmZlNzZmOTUwZWFkZjY1NjpmYWtl
> User-Agent: curl/7.35.0
> Host: 192.168.2.173:3000
> Accept: */*
> Content-Type: application/json
> Content-Length: 72
> 
* upload completely sent off: 72 out of 72 bytes
< HTTP/1.1 200 OK 
< X-Frame-Options: SAMEORIGIN
< X-Xss-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Content-Type: application/json
< Cache-Control: no-cache
< X-Request-Id: 46fc3a7e-78ad-406e-abd1-264351f3d414
< X-Runtime: 1.081898
* Server WEBrick/1.3.1 (Ruby/2.4.1/2017-03-22) is not blacklisted
< Server: WEBrick/1.3.1 (Ruby/2.4.1/2017-03-22)
< Date: Mon, 30 Oct 2017 07:29:37 GMT
< Content-Length: 0
< Connection: Keep-Alive
< Set-Cookie: _redmine_session=ZjNNUnZMc1NWcWVJVnJpYzd0TkhVekVkVkRIOHpuQ1N0R1IvWUZIQUttcnZ3VFNPYTVnMmh2QVdna2pyYTN4SkJmdUY1ZU51cWZsRUs3eVlSMlBSQWtZWCtKSHNDWlFnVDhMK3pFazJ1eTVtREtzU1FWb3dCOVYwcXVwSGNJTFBlbDVQY2NsNllXSGQ0WVVTcXdtQW1LSEVuN1d2LzBXTnZnZFdNUEFGNTZDUVlyb05Ld0RPM3JkTmd1UkdpZjZ4ZjY1YVRDeEIyT0MxWjd4dXRPUStHZz09LS1iNkZoZURldTN6cWR4U0JkSEVyZDJBPT0%3D--dc930ba020465a7df398fb5e2e8197142a83617c; path=/; HttpOnly
< 
* Connection #0 to host 192.168.2.173 left intact

The above was done in a server with a minimal set of plugins present:

Environment:
  Redmine version                3.4.2.stable
  Ruby version                   2.4.1-p111 (2017-03-22) [x86_64-linux-gnu]
  Rails version                  4.2.8
  Environment                    development
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.8
  Git                            1.9.1
  Filesystem                     
Redmine plugins:
  hello                          0.0.1
  polls                          0.0.1
  redmine_changeauthor           1.0.1
  redmine_editauthor             0.11.0
  redmine_knowledgebase          0.0.1

I heard from people that are trying to upgrade Redmine in my company that some plugins are causing '500' errors.

Maybe you are seeing the same problem. You can try to track this down by removing plugins one by one till the issue disappears.

RE: Getting error when updating an issue by REST API using PUT method - Added by Alexandre Mendonça Lima over 6 years ago

Thank you for trying to help me!

My environment is:

Environment:
  Redmine version                3.4.2.stable
  Ruby version                   2.2.6-p396 (2016-11-15) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.10
  Filesystem                     
Redmine plugins:
  redmine_spent_time_required    0.0.1
  redmine_surveys                0.0.2

I'll try to disable plugins and test again.

An other person suggested me that "if any required field is null or an field is missing, then redmine does not update the issue". I'll try to see if log is saying something like "null value" for any field.

RE: Getting error when updating an issue by REST API using PUT method - Added by Alexandre Mendonça Lima over 6 years ago

Hi, Takeshi!

You're right! It was a plugin. I disabled 'redmine_spent_time_required' plugin and my test worked on it. Maybe some field that plugin has using is null. I'll do a deep debug to find what field is causing problem with REST API.

Thank you once more.

    (1-4/4)