This topic contains 4 replies, has 2 voices, and was last updated by  Duo_Liang 1 week, 6 days ago.

  • Author
    Posts
  • Participant
    saraizad
    Newbie
    Member since: 20.12.2018
    Number of posts: 13

    Hi,

    Is there an API available to copy a document from one package to another package?

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 608

    Score

    0

    Hi saraizad,

    Yes, I think Layout Feature fits your scenario.

    #1. create a layout out of your document:

    HTTP Request
    POST /api/layouts
    
    HTTP Headers
    Accept: application/json
    Content-Type: application/json
    Authorization: Basic api_key
    
    Request Payload
    { 
       "name":"layout_name",    
       "type":"LAYOUT",
       "id":"source_package_id",
       "visibility":"SENDER",
       "documents":[ 
          { 
             "id":"source_document_id"
          }
       ]
    }

    #2. retrieve the layout ID from response payload of #1 REST call

    #3. apply the layout to target document:

    HTTP Request
    POST /api/packages/{packageId}/documents/{documentId}/layout?layoutId={layoutId}
    
    HTTP Headers
    Accept: application/json
    Content-Type: application/json
    Authorization: Basic api_key

    Note:
    1.layoutID is the one you got from #2
    2.no need for request payload

    Hope this could help!
    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    Participant
    saraizad
    Newbie
    Member since: 20.12.2018
    Number of posts: 13

    Score

    0

    Hi Duo,
    Thank you for your response, but I’m not sure if I can use that, here is the scenario:
    Package A has Document#1 and Document#2
    Package B has Document#3 and Document#4

    I need to create a package C that has Document#1 and Document#3. I was wondering if there is a way maybe like an API that gets DocumentIds and would clone them into the Package C.

    based on your response, I’m wondering if I can use your solution and create empty files(so smaller payload) and put them into Package C and then use Layout to copy them over to C, do you think that would work?

    Thanks,
    Sara

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 608
    Approved answer

    Score

    1

    Hi Sara,

    Yes, you can use below API to upload an almost empty document (only containing ID and name), and then use this ID to apply layout:

    HTTP Request
    POST /api/packages/{packageId}/documents
    
    HTTP Headers
    Accept: text/html
    Content-Type: multipart/form-data
    Authorization: Basic api_key
    
    Request Payload
    ------WebKitFormBoundary1bNO60n7FqP5WO4t
    Content-Disposition: form-data; name="file"; filename="testDocumentExtraction.pdf"
    Content-Type: application/pdf
    
    %PDF-1.5
    %µµµµ
    1 0 obj
    <>>>
    endobj.... 
    
    ------WebKitFormBoundary1bNO60n7FqP5WO4t
    Content-Disposition: form-data; name="payload"
    
    {
      "id": "document_id",
     "name": "document_name"
    }
    
    ------WebKitFormBoundary1bNO60n7FqP5WO4t--

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    • This reply was modified 1 week, 6 days ago by  Duo_Liang.
    • This reply was modified 1 week, 6 days ago by  Duo_Liang.
    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 608

    Score

    0

    Just a little correction, both ID and name are necessary for uploading a document.

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist

You must be logged in to reply to this topic.