REST API: Categories

I need to post a document to Content Server, preferably using the REST API, but I need to include category and metadata information. I see some similar posts that indicate this functionality is available in the summer time frame of this year. We are currently only version 2014-06 of CS10, fully patched, but I don't see any documentation indicating how to do what I want to do. Is this possible yet? Here are some threads used as my basis for this timeline:

https://developer.opentext.com/webaccess/#url=/awd/forums/questions/9456/timeline+for+rest+api+category+functionality

https://developer.opentext.com/webaccess/#url=/awd/forums/questions/7435/pulling+category+info+via+rest+api

Comments

  • This is possible, here are the steps required:

    1) Create the document first using POST /nodes, with the parameters name=DocumentName, parent_id={parent container id}, type=144, file={path to your file}, file_name={name of the file}, file_content_type=application/msword.

    2) Add a category to the document using POST /nodes/{document id}/categories, with the parameter category_id={category id}

    3) Update the category on the document using PUT /nodes/{document id}/categories/{category id}, with the parameter body={"6511_2":"abc"} (where 6511_2 is {category id}_2, since the _2 refers to the first attribute of that category. subsequent attributes are _3, _4, etc.)

  • I am getting a 400 error on step #2. Do you mean the object ID when you say category ID? Here is my example header:

    POST /otcs/llisapi.dll/api/v1/nodes/288665/categories HTTP/1.1
    Host: serverhostname.domain.com
    OTCSTICKET: mytickethere
    Cache-Control: no-cache

    ----WebKitFormBoundaryE19zNvXGzXaLvS5C
    Content-Disposition: form-data; name="category_id"

    291744
    ----WebKitFormBoundaryE19zNvXGzXaLvS5C

  • I am getting a 400 error on step #2. Do you mean the object ID when you say category ID? Here is my example header:

    POST /otcs/llisapi.dll/api/v1/nodes/288665/categories HTTP/1.1
    Host: serverhostname.domain.com
    OTCSTICKET: mytickethere
    Cache-Control: no-cache

    ----WebKitFormBoundaryE19zNvXGzXaLvS5C
    Content-Disposition: form-data; name="category_id"

    291744
    ----WebKitFormBoundaryE19zNvXGzXaLvS5C

  • It's category ID, see below. Assuming that the ID of your document is 4533 and the ID of your category is 6511 (you can check this in the categories volume of Content Server):

    POST /nodes/4533/categories
    category_id=6511

  • I am not doing something right. Here are some screenshots:

    Authenticating

    enter image description here

    Posting the document

    enter image description here

    Checking the category ID in the categories volume (note this iD is also shown as "objID" in the browser URL at this point)

    enter image description here

    Running Step #2 with a URL parameter key returns value 200 (but as you see below, it does not actually add the category)

    enter image description here

    enter image description here

    If I run step 2 using form-data instead (key/value pair), then I get 400 error.

  • When you're doing the POST /nodes/288666/categories, I notice a parameter after the '?' symbol. What parameter is that, I can't see the whole of it.

    Edit: Oh, I see... it's probably category_id, isn't it? It's just represented on your testing tool as a key-value pair.

    What version is your content server? Is it 10 or 10.5, and which update?

  • Version 10 update 2014-06.. fully updated as of 9/18/2014

  • What is the exact 400 error message you're getting?

  • When posting with form-data rather than a URL parameter, I get the 400 error message.

    This (shown above) gets me a 200 code but does not actually add the category:

    POST /otcs/llisapi.dll/api/v1/nodes/288666/nodes/categories?category_id=291744 HTTP/1.1
    Host: hostname.domain.com
    OTCSTICKET: p3rvqQoyWm3S748ZZ4+LZ7MnpZQU2raIP1hhiT3of9TeNxWBmdbXE9cF0UJ8bVh7
    Cache-Control: no-cache

    This (Form data) gets me the 400 error message:

    POST /otcs/llisapi.dll/api/v1/nodes/288666/categories HTTP/1.1
    Host: hostname.domain.com
    OTCSTICKET: p3rvqQoyWm3S748ZZ4+LZ7MnpZQU2raIP1hhiT3of9TeNxWBmdbXE9cF0UJ8bVh7
    Cache-Control: no-cache

    ----WebKitFormBoundaryE19zNvXGzXaLvS5C
    Content-Disposition: form-data; name="category_id"

    291744
    ----WebKitFormBoundaryE19zNvXGzXaLvS5C

    The exact 400 error is: "The request cannot be filled due to bad syntax."

  • Note that my first REST call in my last reply was not formatted the way you originally said (I was testing trying to get it to work).

    What you said was nodes/{objectID}/categories. This returns a 200 code but does not actually add the category.

    I also tried nodes/{objectID}/nodes/categories, which strangely enough returns a 200 code with the same non-result.

  • nodes/{objectID}/nodes is a browse call (used with the 'GET' verb), it browses the child nodes of that object represented by objectID.

    Would you be able to provide me some info on where you obtained the installer for this content server, as well as all of the patches you applied to it? I'd like to install a local instance and test it out myself.

  • Sure. It has been around for a while. It started with CS 10 SP2 Update 10 from scratch. It was recently updated to 2014-06 in place. Here is a list of the currently installed patches. Is there maybe a patch for the REST API that I am missing? I told you we were fully up to date, but you know how confusing patching can be. There is a possibility that something was overlooked.

    Do you know for sure this should work in 10.5 2014-09? We are in the planning stages for this upgrade, and I may have it running in development soon for testing.

    pat07500.txt

    pat100000001.txt

    pat100000002.txt

    pat100000003.txt

    pat100000005.txt

    pat100000006.txt

    pat100000037.txt

    pat100000070.txt

    pat100000109.txt

    pat100000166.txt

    pat100000199.txt

    pat100000270.txt

    pat100000419.txt

    pat100000449.txt

    pat100000463.txt

    pat100000471.txt

    pat100000500.txt

    pat100000580.txt

    pat100000610.txt

    pat100000617.txt

    pat100000629.txt

    pat100000630.txt

    pat100000660.txt

    pat100000679.txt

    pat100000716.txt

    pat100000722.txt

    pat100000723.txt

    pat100000724.txt

    pat100000725.txt

    pat100000742.txt

    pat100000743.txt

    pat100000753.txt

    pat100000765.txt

    pat100000770.txt

    pat100000771.txt

    pat100000789.txt

    pat100000834.txt

    pat100000852.txt

    pat100000859.txt

    pat100000860.txt

    pat100000862.txt

    pat100000882.txt

    pat100000900.txt

    pat100000906.txt

    pat100000912.txt

    pat100000933.txt

    pat100000934.txt

    pat100000936.txt

    pat100000938.txt

    pat100000958.txt

    pat100001026.txt

    pat100001031.txt

    pat100001050.txt

    pat100001081.txt

    pat100001112.txt

    pat100001130.txt

    pat100001132.txt

    pat100001212.txt

    pat100001236.txt

    pat100001274.txt

    pat100001300.txt

    pat100001350.txt

    pat100001380.txt

    pat100001484.txt

    pat100001505.txt

    pat100001506.txt

    pat100001543.txt

    pat100001549.txt

    pat100001559.txt

    pat100001560.txt

    pat100001562.txt

    pat100001589.txt

    pat100001590.txt

    pat100001596.txt

    pat100001602.txt

    pat100001620.txt

    pat100001621.txt

    pat100001631.txt

    pat100001644.txt

    pat100001645.txt

    pat100001649.txt

    pat100001652.txt

    pat105000186.txt

    pat971104.txt

    pat971156.txt

    pat971293.txt

  • Do you know for sure this should work in 10.5 2014-09? We are in the
    planning stages for this upgrade, and I may have it running in
    development soon for testing.

    This works in 10.5 September update (10.5 2014-09), I have just verified it by installing that on my machine and running the calls that I detailed in my first post (recapped here):

    1. Upload your document using POST api/v1/nodes, with the following parameters:
      name={document name}
      parent_id={id of parent container}
      type=144
      file (use the file tab on your REST tool of choice, make sure the parameter is named 'file')

    2. Add a category to the document using POST api/v1/nodes/{document id}/categories, with the parameter:
      category_id={id of the category}

    3. Update the category using PUT api/v1/nodes/{document id}/categories/{category id}, with the parameter:
      {category id}_2={whatever value you want for the attribute}

    (increment the 2 to 3, 4 etc. for subsequent attributes in that category)

  • BrandonLBrandonL Brandon Lucas

    Okay, I will work on this, validate, and update this thread.

  • for step 1, are the parameters must be pass through URL parameters and not form encoded parameters? I am doing this in .NET

  • Hi, I am facing the same problem as the rest of the guys where the category is not added into the document. I tried to do a direct query into the DTreeCore table but the category id is not been tagged to the document that I have successfully uploaded.

    Anyone has idea on this?

  • What about adding nodes to folders that have categories with REQUIRED attributes on them? I can't get past step 1, a POST to nodes/ results in 400 error with a description: "{"error":"abc is a required field."}" (where "abc" is the name of the required field)

  • BrandonLBrandonL Brandon Lucas

    Even after upgrading to CS 10.5 I still can't update category information for an object I have uploaded. I get a 200 code back indicating success, but the object category data does not update.

    Here is the example header:

    PUT /otcs/llisapi.dll/api/v1/nodes/2165909/categories/2165578?{2165578}_2=here is my text HTTP/1.1
    Host: hostname.domain.com
    OTCSTICKET: WIX36ENs7zVkP3Fe0dT2IWtFoN9GPv5ynn1IS0XAmek0uUvvfCiVAA7D6NDHqmeC
    Cache-Control: no-cache

    Where 2165909 is the object ID of the document, 2165578 is the category ID.

  • BrandonLBrandonL Brandon Lucas

    Nevermind. I finally got it to work!

  • BrandonLBrandonL Brandon Lucas

    Nevermind. I finally got it to work!

  • How did you get it to work, especially with a category with a required attribute? I am running into the same problem and it gives me a bad request message when I try to add the category to the document.

    EDIT: For my part I was using the wrong category id for the document.

  • Hi Brendon Lucas,

    I am facing same issue :

    Even after upgrading to CS 10.5 I still can't update category information for an object I have uploaded. I get a 200 code back indicating success, but the object category data does not update.

    Could you please let me know how it was resolved for you.

    Thanks

  • The problems I had were:

    1. wrong category ID - this caused a bad request response
    2. formatting the request incorrectly somehow (at one point I think I was using a JSON document in a GET request or something like that - it has been a while).

    What enabled me to finally get it working was the ability to see all of the request - since I'm using Chrome I used SureUtils REST API client with copy-paste to test various requests. I also used Fiddler to see everything in the actual communication.

  • For me issue was :

    Wrong Query Parameters : 633383_1 .. Attribute id should starts from 2..(Used 633383_2 and 633383_3).

    Content type for PUT : ( Content-Type : application/multpart/form-data )

  • If it's saying "wrong query parameters" then I would look at the definition of the category that you're trying to use and ensure that you have the correct attributes and values sent.

  • Can somebody explain why it is needed to add category id into resource of attributes update?
    PUT api/v2/nodes/{id}/categories/{category_id}/

    The category id is anyway in body content attributes mappings.
    {category_id}[{set_id}{set_row}]_{attribute_id}

    Current approach limits attribute update by one category by request. Why not to use same mechanism as node create. If needed category will be added by attributes key mapping.

  • It is almost 2019 and still don't know how to upload a document with a category that has in it required attributes.
    I always have to remove the required attributes.

    enter image description here

    What notes ?

  • After reading through this thread several times, I'm trying to convince myself that I understand the general concept as described. But the answer about required categories still hasn't been answered. If I have a required category attached to a folder, and try to upload a file, I get Bad Request. If I upload the same file to a folder without the categories, it works just fine. As @Felipe says, he has to remove the required attributes. Is this the only way around to do this? I'm using the REST API's in 10.5 SP 1.

    EDIT:
    When I uploaded a document with no required attributes, the categories were already created so there was no sense in doing a POST with a Category. When there are required attributes, and since I can't get passed the error message, I'm going to assume that's when you need to do the POST with the Categories.

  • The original solution has you applying a category to a node by POSTing a categoryId, then PUTting the attribute values
    You can combine these into one step with a POST which solves the required attribute issue.
    POST: /OTCS/cs/api/v2/nodes//categories
    with
    form data: category_id and
    form-data: body {this is some json that matches your category template}

    ex:
    category_id=18053,
    body={"18053_2":"ODS190515_00008","18053_3":"219483289","18053_4":"Vision Care","18053_5":"2019-04-23 09:59:31.641","18053_6":"219483289"}

Sign In or Register to comment.