I've been trying to get the Duplicate Invoices check Store Validation JS Node webservice to work. I thought it would be pretty simple to adapt the sample for such a service Docuware has available on its Developers website.
So, after spending a lot of effort on this, the service that is accessing my Docuware Cloud system (7.2)  runs correctly only once or twice before giving me 401 error, and then I have to wait awhile before I can use the service again.
401 error means Authentication problem, and most likely the license I use to access Docuware system is not being released from previous access. I've been told that I need to use Token instead of username/password login for attempts after the 1st one. Unfortunately I have no idea how to that in the JS program. Can anyone assist? I have the following code - this is exactly how it came from the downloaded sample. 
*************************
exports.isDuplicateInvoice = function (fileCabinetGUID, invoiceNo) {
    return new Promise((resolve, reject) => {    
        var CookieJar = unirest.jar(true);
        //logon to DW PLATFORM and retrieve cookie;
        unirest.post(DWparameters.DWPlatformUrl + '/Account/Logon')
        .headers({'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded'})
        .jar(CookieJar)
        .send({ 'UserName': DWparameters.DWPlatformUser, 'Password': DWparameters.DWPlatfromPassword, 'Organization': DWparameters.DWPlatformOrganization, 'RememberMe': false, 'RedirectToMyselfInCaseOfError': true })
        .end(function (response) {
            unirest.post(DWparameters.DWPlatformUrl + '/FileCabinets/'+ fileCabinetGUID +'/Query/DialogExpression?dialogId='+ DWparameters.DWSearchDialogGUIDForInvoiceSearch +'&format=table')
            .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
            .jar(CookieJar)
            .send({ 'Condition':[
                { 'DBName':DWparameters.fieldNameDOCNUMBER, 'Value': [invoiceNo] },
                ],
            'SortOrder':[],'ForceRefresh':true,'FlagConditions':{'IncludeCheckedOut':false},'Operation':'And','AdditionalResultFields':[],'Start':0,'Count':1})
            .end(function (response) {
                if (response.error) {
                    return reject(new Error(response.error.message));
                }
                try {
                    var resultCount = response.body.Count.Value;
                    return resolve(resultCount == 0);                
                } catch (error) {
                    return reject(new Error("Unable to retrieve similar invoices. Error:" + error));
                }
            });
        });
    })
}