Fiona

Document getData() returns empty

0 votes

We need to retrieve the document associated data using the SDK. In Postman, we can view the document data using REST /packages/{packageId}/documents/{documentId}.  However, we are getting an empty map using the getData() method.  Is there a way to retrieve this data using the SDK?  

{
    "status": "",
    "description": "",
    "id": "DOCUMENT-2",
    "external": null,
    "data": {
        "Indexing_Type_Code": "",
        "Document_ID": "8720",
        "File_Name": "TEST DOC.PDF",
        "Borrower_FirstName": "Tammy",
        "Borrower1_LastName": "Test",

.....

}


Reply to: Document getData() returns empty

0 votes

Hi Fiona,

 

At first glance, .getData() should be the correct function to use, as the "Custom Document Data" guide suggested, or something around below code:

            DocumentPackage pkg = eslClient.getPackage(packageId);
            Document document = pkg.getDocuments().stream()
                    .filter(doc -> doc.getId().getId().equals("DOCUMENT-2"))
                    .findFirst()
                    .get();
                    
            Map<String, Object> attributes = document.getData();

 

If the issue consistent, do you mind sharing this package ID to me?

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Document getData() returns empty

0 votes

Unfortunately due to GDPR compliance, "documents" -> "data" was removed from backoffice, therefore I was not able to help you check it. Can you utilize any JSON library(org.json, fast JSON, etc) and print out the JSON string of the Document or the whole DocumentPackage object and see if the data was converted to SDK modelling?

            String jsonString = com.alibaba.fastjson.JSON.toJSONString(document);
            String jsonString2 = new org.json.JSONObject(pkg).toString();

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Document getData() returns empty

0 votes

I was hoping I can avoid the REST call to get this custom document data.  I wonder if this is a bug.  Should I submit a ticket and provide the credentials for you to check out this issue?


Reply to: Document getData() returns empty

0 votes

Hi Fiona,

 

Yes, this is not expected, and shouldn't require extra REST call to get the document attribute. If you shared your availability this afternoon, we can arrange a quick Zoom session, or if you preferred to keep it an official record, you can submit the issue to [email protected] and our support agent will reply back to you soon.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Document getData() returns empty

0 votes

Hi Fiona,

 

As we discussed in the session, this is because the API is not returning all properties when pulling multiple payloads and I have submitted a support ticket on your behalf and we will report this to R&D team.

 

In the very short term, you can use below code as a workaround:

        Date START_DATE = new LocalDateTime(2020, 1, 1, 0, 0).toDate();
        Date END_DATE = LocalDateTime.now().toDate();
        List<DocumentPackage> listOfPkgs = eslClient.getPackageService().getUpdatedPackagesWithinDateRange(PackageStatus.COMPLETED,
                new PageRequest(1, 50), START_DATE, END_DATE).getResults();
        
        List<PackageId> listOfPkgIds = listOfPkgs.stream().map(pkg->pkg.getId()).collect(Collectors.toList());
        listOfPkgs = listOfPkgIds.stream().map(pkgId->eslClient.getPackageService().getPackage(pkgId)).collect(Collectors.toList());

Because the issue is at API level, I don't have a good option to avoid pulling each package JSON.

 

In the long term, hopefully this will be fixed quickly, but in case this is by designed, I would suggest you to put the custom data at package attribute level with naming convention like

"document1_Indexing_Type_Code":""

"document1_Document_ID", "135526"

 

Duo
        

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off