Getting error while calling sdk.createDocuments(packageId, document, doc)

0 votes


I am using the sample code for creating a transaction but getting an error - 

Bad Request - {"messageKey":"error.validation.invalidParameters","technical":"Unexpected Content-Disposition value for parameter 'name'","message":"Invalid parameters.","code":400,"name":"Validation Error"}

while calling sdk.createDocuments(packageId, document, doc);

Please let me know if i am missing anything. Screenshots attached having the code.



Reply to: Getting error while calling sdk.createDocuments(packageId, document, doc)

0 votes

Hi prnygupta123,


Thanks for your post! Although I can't reproduce the error with the same code, there's actually another way to create a package. Could you try with below code where the transaction, signers and documents are uploaded in a single call "sdk.createPackage(pkg,documentBlobMap)" instead of separate steps:

(Also, I don't think there's any problem there but please make sure you have created a static resource with name of "testdoc1" in your Salesforce environment)


        OneSpanSDK sdk = new OneSpanSDK();
        //Create package
        OneSpanAPIObjects.Package_x pkg = new OneSpanAPIObjects.Package_x(); = 'Example Transaction - ' +;
        pkg.status = OneSpanAPIObjects.PackageStatus.SENT;
        //Create Roles
        String roleId1 = 'Signer1';
        OneSpanAPIObjects.Role role1 = new OneSpanAPIObjects.Role();
        role1.signers = sdk.createRolesSigner('John', 'Smith', '[email protected]', 'CEO', 'ABC Bank'); = roleId1; = roleId1;
        pkg.roles = new List<OneSpanAPIObjects.Role>{role1};    //add role

        //Prepare Documents Blob
        String document1Name = 'Document1';
        StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc1' LIMIT 1];
        Map<String,Blob> documentBlobMap = new Map<String,Blob>();
        documentBlobMap.put(document1Name, sr.Body);
        //Create Document Metadata
        OneSpanAPIObjects.Document document1 = new OneSpanAPIObjects.Document(); = document1Name; = document1Name;
        OneSpanAPIObjects.Field field = new OneSpanAPIObjects.Field();
        field.left = 208;
        field.width = 200;
        field.height = 50; = 518; = 0;
        field.subtype = 'CAPTURE';
        field.type = 'SIGNATURE';
        List<OneSpanAPIObjects.Field> fields = new List<OneSpanAPIObjects.Field>();
        OneSpanAPIObjects.Approval approval = new OneSpanAPIObjects.Approval();
        approval.fields = fields;
        approval.role = roleId1;

        List<OneSpanAPIObjects.Approval> approvals = new List<OneSpanAPIObjects.Approval>();
        document1.approvals = approvals;

        pkg.documents = new List<OneSpanAPIObjects.Document>{document1};    //add document
        //Send package One Step
        String packageId = sdk.createPackage(pkg,documentBlobMap);
        System.debug('PackageId: ' + packageId);



Duo Liang OneSpan Evangelism and Partner Integrations Developer

Reply to: Getting error while calling sdk.createDocuments(packageId, document, doc)

0 votes

Hi Duo,

Thanks for your response. I just changed the pdf file in the static resource and it started working for me. So all good now. 


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