REST API create node with category is returning "Could not process object, invalid action 'create'"

Options

Hi Team,

This is on DEVELOPMENT environment of OTCS23.3.

We are trying to upload document with category from tibco application using REST API.

But returning the error message highlighted in yellow.

(Using postman, I am able to upload and create category as well.)

 

Step 1: I invoked Authentication API (http://OTDEV/OTCSadmin/llisapi.dll/api/v1/auth), got the session ID.

Step 2: Invoked second API (http://OTDEV/OTCSadmin/llisapi.dll/api/v2/nodes) to upload the documents along with category and attributes. In header we used the session ID returned from Step 1.

 

The second API returned the below error output.

 

<?xml version = "1.0" encoding = "UTF-8"?>

<ns0:RESTOutput xmlns:ns0 = "">

      <StatusCode>500</StatusCode>

      <msg>{"error":"Could not process object, invalid action 'create'","request_id":"78c67f0c-44d2-4994-8bad-091945f44e13"}</msg>

</ns0:RESTOutput>

 

 

Below is the Request to Second API: This exactly same as how we are passing from your postman collection.

 

<?xml version = "1.0" encoding = "UTF-8"?>

<ns0:ActivityInput xmlns:ns0 = "">

      <ns0:Parameters>

            <Header>

            <Content-Type>application/x-www-form-urlencoded</Content-Type>

            <otcsticket>ce67559a8f6d7b65e189b45b76b14b29f232e015dfe81c41d23351ac1433bc06fb021fc91a6216ef26dd6a219685c30792925374c505739fb76ef24febf5aaed</otcsticket>

            </Header>

            <Body>

                  <Text>

                        <type>application/x-www-form-urlencoded</type>

                        <body>

                        {

                              "name": "REF_02242023_1284.pdf",

                              "parent_id": "9681941",

                              "type": "144",

                              "roles": {

                                    "categories": {

                                          "149088_14": "1968",

                                          "149088_15": "133 Excise MF FET January 31 2023",

                                          "149088_16": "INTERNAL REVENUE SERVICE - GA"

                                                      }

                                          }

                        }

                        </body>

                        <file>\\hoaadv3333\operations\Kofax\Export\00000504\1.pdf</file>

                  </Text>

            </Body>

      </ns0:Parameters>

</ns0:ActivityInput>

 

Regards,

Vishnuhttp://www.tibco.com/namespaces/tnt/plugins/jsonhttp://www.tibco.com/namespaces/tnt/plugins/json

Comments

  • appuq
    edited March 5 #2
    Options

    OT does not accept Files like a share like you have shown <file>\\hoaadv3333\operations\Kofax\Export\00000504\1.pdf</file>

    The proper way to send a file to CS is through a POST using multipart/form data thousands of examples exist in this forum. Find a JS example in this forum(read implementation notes specifically)

    If I am not mistaken I shared a Java file in this forum as I had this same need and I found a POJO doing a file upload using multipart form data and I repurposed it. Sorry this forum is very difficult to search things so perhaps you can find a JS version and repurpose it for your coding language

    re-reading I think you are sending it with the fake body but it is very susceptible to errors

    here's a working Postman payload

    POST /OTCS/cs.exe/api/v2/nodes HTTP/1.1
    Host: localhost:8080
    otcsticket:
    Content-Length: 796
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="type"

    144
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="parent_id"

    296125
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="name"

    Filename for CS2
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="file"; filename="///REST API Examples.postman_collection.json"
    Content-Type: <Content-Type header here>

    (data)
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="body"

    {
    "roles": {
    "categories": {
    "481355_2": "RH123",

    }
    ----WebKitFormBoundary7MA4YWxkTrZu0gW

    in my blog https://appukili.wordpress.com/ I have put the java file I usually use I called it JAVA REST API EXPERIMENTS .docx the actual code file that i shared is called DocumentHelper.java I would see if that worked somehow as I think it is heavily commented

    I need to move all of this resources to my own place as OT is retiring CS links

    BTW I think you are almost right it may be the attribute name like file ,body etc so you can cross check with some of my code or stuff existing in this forum

  • PaVishnu
    Options

    Thank you, Appu. I shall check the examples you have provided.

  • appuq
    Options

    The easiest method is JS search for @Ferdinand Prantl 's many many examples in this forum most of the times he puts out examples using JS and C# so it is quickly testable. He usually puts out why certain things have to be done that way as well :) or @Nizar Ghazal I had to go with POJO because for the life of me I did not know how to deploy high level REST packages in java in the application server I was working which was IBM WebSphere .

  • PaVishnu
    Options

    Hi Appu,

    Thank you for examples, we are sending Document path as a shared location, OpenText is not accepting it.

    But in real time, we fetch this document path from Kofax table. It is a shared drive location.

    Even when tried from postman collection by providing the shared path location. It didn't work as well.

    It is working only if you provide local path like c:\1.pdf.

    Please advise.

    Regards,

    P.A.Vishnu

  • PaVishnu
    Options

    Hi Appu,

    When we are sending Document path as a shared location like

    \\hoaadv3333\operations\Kofax\Export\00000504\1.pdf

    we fetch this document path from Kofax table. It is a shared drive location. 

    Opentext is not accepting this sharedpath.

    Also when tried from postman collection by providing the shared path location. It didn't work as well.

    It is working only if we provide local path like c:\1.pdf.

    Please advise.

    Regards,

    P.A.Vishnu

  • PaVishnu
    Options

    Hi Appu,

    When we are sending Document path as a shared location like

    \\hoaadv3333\operations\Kofax\Export\00000504\1.pdf

    we fetch this document path from Kofax table. It is a shared drive location. 

    Opentext is not accepting this sharedpath.

    Also when tried from postman collection by providing the shared path location. It didn't work as well.

    It is working only if we provide local path like c:\1.pdf.

    Please advise.

    Regards,

    P.A.Vishnu

  • appuq
    edited April 2 #8
    Options

    The path needs to be selectable (open /See in Windows) by POSTMAN control. If you think about it when you invoke Postman you are accessing it as the user on your logged-in computer so to upload a file you need access. To figure out your problem in classic GUI do an Add Item document use the control and select this file \\hoaadv3333\operations\Kofax\Export\00000504\1.pdf using the file selector, does it work? use the smartui and do the same that is what you are doing with the REST API.

    If you store a path in a table that is a string…Livelink will accept only a File where FileName is the string…

    but there are more properties to the file object than just a name.

    I would check permissions to the file system rather than thinking it cannot be done😊

    I trimmed our server and the file path but from the screencap, you can see that I am uploading a file that is in an azure file system…

    BTW Vishnu when Postman sends a file that easily it is doing a multipart/form-data POST that is very hard for new-age developers to understand. What we all do now is use higher APIs like CURL,restsharp,java etc but all they are doing is still an HTTP POST.

    POST /otcs/cs.exe/api/v1/nodes HTTP/1.1
    Host: server.qellus.com:8080
    otdsticket: OTDSSSOA
    Content-Length: 635
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

    ------WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="type"

    144
    ------WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="parent_id"

    2000
    ------WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="name"

    Filename for CS
    ------WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="file"; filename="///servername.file.core.windows.net/softwaredownloads/software/Useful/APPU TEST DATA/OTCSSA_1628_Content Server 16.2.8 System Administrator Certification.pdf"
    Content-Type: <Content-Type header here>

    (data)
    ------WebKitFormBoundary7MA4YWxkTrZu0gW--