400 Bad Request error: "Could not get parent" Creating Node

Options

Content Server 10.5 Update 2014-12 (version 10.5.0.10)

Hi,

Issue occurred in my apps REST request, however to troubleshoot and simplify I've used Chromes extension Advanced REST Client. When I try and add a node to OTCS (have tried both documents and folders), I receive the following response:

error: "Could not get parent"

Host & Path: http://enterprise/otcs/llisapi.dll/api/v1/nodes

RAW request: name=new_doc&type=144&parent_id=2000 ... have also tried name=newfolder&type=0&parent_id=2000

Header: OTCSTICKET

Method: POST

I've tried other containers apart from 2000 in OTCS and am logging in with an admin account so permissions are not the issue. I've also successfully added a version to a document, the only request that appears to be problematic is the POST /NODES

Thanks in advance,

========
Header request/response:

Status
400 400 Bad Request Show explanation Loading time: 151

Request headers
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36
OTCSTICKET: q3Whg56WBqIgGGA+lEufxs/qebF3aoUlJWngMYStwnQ=
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryDOB7QMkPMNLBSKaa
Accept: /
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Cookie: AdminPwd=iTkE%2BsnxoZmZa5GbcZX54mIKB%2FVk4iDUK%2BdK5WAKdFgvjBeeFld7TUdYLGx5Ms%2BGHDH%2FGPUJfR3Mk7i6KYZzb%2F5xdRmb8Z7Sy0bDFblAdZ6r1N9TWWst1V9v20LRYgTjRkqbU%2BNzGPygDkdNURx6x1BlWFRPewJzkUZjQhg2T5GmalecrPImaYWGP0aq%2FYnbzfH%2BPwzmMo3CjtCt8MgCjzE%2FbuWlOk84rkiGWBI5FY9KAIWi2DS4fiSZeErI1ykG; LastDestID=1894187; LLCookie=UA3wXPCRCW67vmmLTMqJ51nazA%2FF2cYK6298ZeBI2JA%3D; LLView_ID=9; BrowseSettings=uyECTato2uEK%2FHs9IhTUB%2F2JqQUwQpPvCOvbqL3A5bE%3D; LLTZCookie=0; adminStyle=all; cv_page=Features; accessToken=d8682c3496bea117e69a2376885e7aef

Response headers
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Pragma: no-cache
Content-Length: 32
Content-Type: application/json; charset=UTF-8
Expires: 0
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
Access-Control-Allow-Headers: OTCSTicket, OTDSTicket, MYSAPSSO2, Authorization, Content-Type, Content-Length
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Expose-Headers: OTCSTicket, Content-Type
Access-Control-Max-Age: 86400
Status: 400 Bad Request
X-Powered-By: ASP.NET
Date: Wed, 01 Apr 2015 18:43:55 GMT

Tagged:

Comments

  • are you uploading a file as well or just trying to create a folder?

  • Hi Jason,

    I am just trying to upload a file to an existing folder or the Enterprise workspace. I added a file to the request via the chrome extension and named the form field "file". Apart from that I get the same error when simply trying to create a folder using POST /NODES (RAW name=newfolder&type=0&parent_id=2000)

  • I have experienced similar problems with uploading files. The solution has always involved minor tweaks to content-type headers or parametrizing the form. Can you share the javascript code?

  • Hi,

    I am having the similar problem, any of you have a solution?

    Thank you

  • You put content type multipart/form-data to the header, but the request body name=newfolder&type=0&parent_id=2000 is not of this content type. Either fix the content type to correspond with your body - application/x-www-form-urlencoded, or format the request body as multipart MIME. The former is simpler and can be used for types without content (document has content but folder has not, for example). The latter is supported by FormData in JavaScript.

    Your parameters to create a new folder are correct. If you want to create a document, you will need to add the file field and thus use the multipart/form-data content type, to be able to add raw file content.

  • If you use jQuery >= 1.6, this is how you create a folder:

    $
      .ajax({
        url: '.../api/v1/nodes',
        method: 'POST',
        headers: {OTCSTicket: '...'},
        data: {
          type: 0,
          parent_id: 9255,
          name: 'My Test'
        }
      })
      .done(function (response) {
        console.log('New folder:', response.id);
      })
      .fail(function (request) {
          console.log('Creating folder failed:', request.responseJSON.error);
      });
    

    There is a post in this forum about uploading a document too.

  • any update on this issue