2 Replies Latest reply on May 22, 2017 9:09 AM by kgrodrigues@hotmail.com

    Uploading attachment to a ticket via the API

    vikramp

      I am trying to upload an attachment to a Ticket in Web Help Desk as per the REST API documentation.

      I am receiving a 405 Method Not Allowed from the API.

       

      Per the documentation these are the following steps:

      1. Getting the Session Key

      $ curl -v -X GET "http://204.155.137.11:8081/helpdesk/WebObjects/Helpdesk.woa/ra/Session?username=admin&password=***"
      * Trying 204.155.137.11...
      * Connected to 204.155.137.11 (204.155.137.11) port 8081 (#0)
      > GET /helpdesk/WebObjects/Helpdesk.woa/ra/Session?username=admin&password=*** HTTP/1.1
      > User-Agent: curl/7.40.0
      > Host: 204.155.137.11:8081
      > Accept: */*
      >
      < HTTP/1.1 200 OK
      < Server: Apache-Coyote/1.1
      < Set-Cookie: JSESSIONID=68B6DC640E82531E782A136831A89560; Path=/helpdesk/; HttpOnly
      < cache-control: private
      < cache-control: no-cache
      < cache-control: no-store
      < cache-control: must-revalidate
      < cache-control: max-age=0
      < date: Wed, 04-Mar-2015 17:19:27 GMT
      < expires: Wed, 04-Mar-2015 17:19:27 GMT
      < pragma: no-cache
      < x-webobjects-loadaverage: 3
      < x-webobjects-servlet: YES
      < Content-Type: application/json;charset=UTF-8
      < Content-Length: 91
      <
      {"type":"Session","sessionKey":"QOpgHSN7BQtPM585N7EcO0","currentTechId":1,"instanceId":-1}
      * Connection #0 to host 204.155.137.11 left intact

      2. Creating att.raw with the following contents

      $ cat att.raw (0)
      POST /helpdesk/attachment/upload?type=jobTicket&entityId=75&returnFields=id,uploadDate HTTP/1.1
      Host: 204.155.137.11:8081
      Cookie: JSESSIONID=68B6DC640E82531E782A136831A89560; wosid=QOpgHSN7BQtPM585N7EcO0
      Content-Type: multipart/form-data; boundary====1400591996857===
      Cache-Control: no-cache
      Pragma: no-cache
      User-Agent: Java/1.7.0_55
      Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
      Connection: keep-alive
      Content-Length: 786

      --===1400591996857===
      Content-Disposition: form-data; name="fileUpload"; filename="my.ini"
      Content-Type: null
      Content-Transfer-Encoding: binary

      # MySQL Server Instance Configuration File
      # ----------------------------------------------------------------------
      ... the rest of the file...

      --===1400591996857===--

      3. Send POST request to API

      $ curl -v -X POST -d @att.raw "http://204.155.137.11:8081/helpdesk/WebObjects/Helpdesk.woa/ra//helpdesk/attachment/upload?type=jobTicket&entityId=75&returnFields=id,uploadDate"
      * Trying 204.155.137.11...
      * Connected to 204.155.137.11 (204.155.137.11) port 8081 (#0)
      > POST /helpdesk/WebObjects/Helpdesk.woa/ra//helpdesk/attachment/upload?type=jobTicket&entityId=75&returnFields=id,uploadDate HTTP/1.1
      > User-Agent: curl/7.40.0
      > Host: 204.155.137.11:8081
      > Accept: */*
      > Content-Length: 733
      > Content-Type: application/x-www-form-urlencoded
      >
      * upload completely sent off: 733 out of 733 bytes
      < HTTP/1.1 405 Method Not Allowed
      < Server: Apache-Coyote/1.1
      < x-webobjects-loadaverage: 3
      < x-webobjects-servlet: YES
      < Content-Length: 0
      < Date: Wed, 04 Mar 2015 18:49:48 GMT
      <
      * Connection #0 to host 204.155.137.11 left intact

      I have tried the same from a Java application with the same results.
      The above server is running 12.2.0 - Build #12.2.0.9011
      I have tried the same thing on another server running 12.2.0 - Build #12.2.0.9030-393358
      with the same results as well

      .