Output 400 rather than 500 error when Stash can't recognize/parse JSON objects properly

XMLWordPrintable

      When using used the following call:

      curl -v -H "Content-Type: application/json" -H "Accept: application/json" -u 'user:pass' -X POST --data-binary @data http://localhost:7990/rest/api/1.0/projects/LULU/repos/lulu/pull-requests
      

      Where data contains:

      {
          \\"title\\": \\"Talking Nerdy\\",
          \\"description\\": \\"It’s a kludge, but put the tuple from the database in the cache.\\",
          \\"state\\": \\"OPEN\\",
          \\"open\\": true,
          \\"closed\\": false,
          \\"fromRef\\": {
              \\"id\\": \\"refs/heads/branch1\\",
              \\"repository\\": {
                  \\"slug\\": \\"lulu\\",
                  \\"name\\": null,
                  \\"project\\": {
                      \\"key\\": \\"LULU\\"
                  }
              }
          },
          \\"toRef\\": {
              \\"id\\": \\"refs/heads/master\\",
              \\"repository\\": {
                  \\"slug\\": \\"lulu\\",
                  \\"name\\": null,
                  \\"project\\": {
                      \\"key\\": \\"LULU\\"
                  }
              }
          },
          \\"reviewers\\": [
              {
                  \\"user\\": {
                      \\"name\\": \\"rluispereiramartins\\"
                  }
              }
          ]
      }
      

      The response is 500 rather than being 400. It's not about the content of "data" but how it's formatted. If you don't have the double quotes escaped, it will run fine:

      * Adding handle: conn: 0x7f8779803000
      * Adding handle: send: 0
      * Adding handle: recv: 0
      * Curl_addHandleToPipeline: length: 1
      * - Conn 0 (0x7f8779803000) send_pipe: 1, recv_pipe: 0
      * About to connect() to localhost port 7990 (#0)
      *   Trying ::1...
      * Connected to localhost (::1) port 7990 (#0)
      * Server auth using Basic with user 'rluispereiramartins'
      > POST /rest/api/1.0/projects/LULU/repos/lulu/pull-requests HTTP/1.1
      > Authorization: Basic cmx1aXNwZXJlaXJhbWFydGluczpybHVpc3BlcmVpcmFtYXJ0aW5z
      > User-Agent: curl/7.30.0
      > Host: localhost:7990
      > Content-Type: application/json
      > Accept: application/json
      > Content-Length: 699
      > 
      * upload completely sent off: 699 out of 699 bytes
      < HTTP/1.1 500 Internal Server Error
      * Server Apache-Coyote/1.1 is not blacklisted
      < Server: Apache-Coyote/1.1
      < X-AREQUESTID: 719x160x0
      < Set-Cookie: JSESSIONID=3E3411D8C461E65F73BAAD13877E5C55; Path=/; HttpOnly
      < X-AUSERNAME: rluispereiramartins
      < X-AUSERID: 1
      < X-ASESSIONID: lrcpv6
      < Cache-Control: no-cache, no-transform
      < Vary: X-AUSERNAME,Accept-Encoding
      < Transfer-Encoding: chunked
      < Content-Type: application/json;charset=UTF-8
      < X-Content-Type-Options: nosniff
      < Date: Fri, 10 Jan 2014 10:59:40 GMT
      < Connection: close
      < 
      * Closing connection 0
      {"errors":[{"context":null,"message":"An error occurred while processing the request. Check the server logs for more information.","exceptionName":null}]}
      

      For reference: https://developer.atlassian.com/static/rest/stash/2.10.1/stash-rest.html#idp8848

            Assignee:
            Kristy
            Reporter:
            ThiagoBomfim (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: