TRIRIGA

 View Only
Expand all | Collapse all

Tririga Connector - upload SOAP API - upload Documents

  • 1.  Tririga Connector - upload SOAP API - upload Documents

    Posted Tue September 12, 2023 02:46 PM

    We are on Tririga 11.1 / Platform 4.1.1
    We have a use case where we are using a OCR / Scanning solution to extract data from the Payables Invoices we receive from our Vendors.
    We create Payment Records (Invoices) for our Leases in IBM Tririga using IO imports.

    We also want to create IBM Tririga Documents using the pdf files that we send for OCR / Scanning. And create an association between the Invoice Records and the Document record in IBM Tririga.

    To create the Document in IBM Tririga we are using
    Step 1. Create the Document Record using IBM Tririga Connector for Business Application saveRecord API https://<tririga-url>/ws/TririgaWS operation saveRecord
    Payload
    <ws:saveRecord xmlns:ws="http://ws.tririga.com">
        <ws:IntegrationRecords xmlns:dto="http://dto.ws.tririga.com">
            <!--Zero or more repetitions:-->
            <dto:IntegrationRecord>
                <dto:actionName>CREATE</dto:actionName>
                <!--Optional:-->
                <dto:guiId>106615</dto:guiId>
                <dto:id>-1</dto:id>
                <!--Optional:-->
                <dto:key>string</dto:key>
                <dto:moduleId>11</dto:moduleId>
                <!--Optional:-->
                <dto:name>Document</dto:name>
                <!--Optional:-->
                <dto:objectPath>\ROOT\Object Attachments\InvoiceFolder</dto:objectPath>
                <dto:objectTypeId>106615</dto:objectTypeId>
                <dto:objectTypeName>Document</dto:objectTypeName>
                <!--Optional:-->
                <dto:projectId>1</dto:projectId>
                <dto:sections>
                    <!--1 or more repetitions:-->
                    <dto:IntegrationSection>
                        <!--Optional:-->
                        <dto:fields>
                            <!--Zero or more repetitions:-->
                            <dto:IntegrationField>
                                <dto:name>Name</dto:name>
                                <dto:value>ABC-Test-Doc9999.pdf</dto:value>
                            </dto:IntegrationField>
                        </dto:fields>
                        <dto:name>General Info</dto:name>
                    </dto:IntegrationSection>
                </dto:sections>
            </dto:IntegrationRecord>
        </ws:IntegrationRecords>
    </ws:saveRecord>

    We are succesfully getting a recordId Back and can see it in IBS_SPEC. We also compared the API created record to a Document created from UI (Document Manager) and it looks good. We can also see this record in Document Manager (without the file)

    Step 2. Upload the file to the Document Record using IBM Tririga Connector for Business Application upload API https://<tririga-url>/ws/TririgaWS operation upload
    Payload
    <ws:upload xmlns:ws="http://ws.tririga.com">
        <ws:content xmlns:con="http://content.dto.ws.tririga.com">
            <con:content>ZQ==</con:content>
            <con:recordId>10</con:recordId>
        </ws:content>
    </ws:upload>

    recordId - The recordId (IBS_SPEC_ID) got from step 1.
    content - passed binary content. Also tried Bas64 content, Also tried Byte Array Content without any success

    API is giving below error when binary is being passed

    <ns2:message>
    PreparedStatementCallback; SQL [INSERT into DM_UPLOAD (  token, filename, filesize, userid)  values(?,?,?,?)]; ORA-01400: cannot insert NULL into ("TRIRIGA"."DM_UPLOAD"."FILENAME")
    ; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("TRIRIGA"."DM_UPLOAD"."FILENAME")
    </ns2:message>

    Document clearly states that for "Document" objects we shouldn't pass File Name, It will take it from Record.
    fileName - If the record is a Document object, the file name from the record will be used.


    Has someone used IBM Tririga Connector for Business Application to create Documents with Binary Files.

    We really appreciate your help.



    ------------------------------
    Vikram Hebbar
    ------------------------------


  • 2.  RE: Tririga Connector - upload SOAP API - upload Documents

    Posted Fri September 15, 2023 03:23 PM

    Don't Bother, I found the solution using Oslc using pointers from other online blogs

    Step 1: Same as Above - Create the Document Record using IBM Tririga Connector for Business Application saveRecord API https://<tririga-url>/ws/TririgaWS operation saveRecord. Payload - See Above. Now we have teh recordId (IBS_SPEC.SPEC_ID) for the Document record, but it still doesn't have the Binary Content in DM_CONTENT using reference IBS_SPEC.SPEC_ID > DM_SMART_OBJECT_CONTENT.SMART_OBJECT_ID / CONTENT_ID > DM_CONTENT.CONTENT_ID

    Step 2 - Upload the Binary Content (PDF File in my case) IBM Tririga Connector for Business Application operation upload doesn't work. So we looked at OSLC APIs. Thanks to Blogs https://www.linkedin.com/pulse/uploading-documents-records-tririga-oslc-nick-schwake/ and https://github.com/IBM/tririga-api/blob/main/markdowns/oslccheatsheet.md, I was able to get pointers

    To upload Binary Content

    Invoke URL : https://tririga.zzzzz.com/oslc/so/triDocumentRS/<pDocRecordId>/Content

    Replace <pDocRecordId> with RecordId returned by Step 1 (Document Record)

    Http-Method = PUT

    Http Headers

    Content-Type application/pdf
    authorization Basic TTTTXXXXX (replace with your credentials)
    Accept application/json
    Slug FilenameBeingUploaded.pdf (replace with your filename)
    x-document-description Test Image 5  (replace with your description)
    x-document-meta \ROOT\Object Attachments\TestFolder (replace with your folder. Folder should exist in Document Manager)
    Properties *
    Step 2 - Associate with you Invoice (Or any other cst Record)

    https://<tririga-url>/ws/TririgaWS 

    operation associateRecord

    <ws:associateRecords xmlns:ws="http://ws.tririga.com">
        <ws:Associations xmlns:dto="http://dto.ws.tririga.com">
            <dto:Association>
                <dto:associationName>Has Document</dto:associationName>
                <dto:associatedRecordId>recordId1</dto:associatedRecordId>
                <dto:recordId>recordId2</dto:recordId>
            </dto:Association>
        </ws:Associations>
    </ws:associateRecords>

    recordId1 - recordId of the Document Created in Step 1

    recordId2 - recordId of the your cst Document that you need to attach the Document to.



    ------------------------------
    Vikram Hebbar
    ------------------------------