Status: Open
Status: Answered
Status: Closed
Status: Duplicate

REST API: Categories

1
Posted Sep 29 by Brandon Lucas.

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=%2Fawd%2Fforums%2Fquestions%2F9456%2Ftimeline%2Bfor%2Brest%2Bapi%2Bcategory%2Bfunctionality

https://developer.opentext.com/webaccess/#url=%2Fawd%2Fforums%2Fquestions%2F7435%2Fpulling%2Bcategory%2Binfo%2Bvia%2Brest%2Bapi

28 Answers

1
BEST ANSWER: As chosen by the author.

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.)


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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

Authenticating

![enter image description here][1]

Posting the document

![enter image description here][2]

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.

[1]: http://s30.postimg.org/f2k72ht9t/image.png "image 1"
[2]: http://s27.postimg.org/skd7z0mpf/image.png "2"


0
BEST ANSWER: As chosen by the author.

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?


0
BEST ANSWER: As chosen by the author.

That would be:

https://serverhostname.domain.com/otcs/llisapi.dll/api/v1/nodes/288666/nodes/categories?category_id=291744


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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."


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

> 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)


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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?


1
BEST ANSWER: As chosen by the author.

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)


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

Nevermind. I finally got it to work!


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

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


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

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 )


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

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.


0
BEST ANSWER: As chosen by the author.

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 ?


0
BEST ANSWER: As chosen by the author.

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.


 You have subscribed and will receive email notifications of updates to this topic. To unsubscribe, uncheck the checkbox.

Statistics

Related categories

Your answer

To leave an answer, please sign in.