Getting error while calling sdk.createDocuments(packageId, document, doc)
Monday, March 21, 2022 at 07:31amHi,
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.
Thanks
Reply to: Getting error while calling sdk.createDocuments(packageId, document, doc)
Monday, March 21, 2022 at 01:53pmHi 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();
pkg.name = 'Example Transaction - ' + Datetime.now().format();
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');
role1.id = roleId1;
role1.name = 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();
document1.name = document1Name;
document1.id = document1Name;
OneSpanAPIObjects.Field field = new OneSpanAPIObjects.Field();
field.left = 208;
field.width = 200;
field.height = 50;
field.top = 518;
field.page = 0;
field.subtype = 'CAPTURE';
field.type = 'SIGNATURE';
List<OneSpanAPIObjects.Field> fields = new List<OneSpanAPIObjects.Field>();
fields.add(field);
OneSpanAPIObjects.Approval approval = new OneSpanAPIObjects.Approval();
approval.fields = fields;
approval.role = roleId1;
List<OneSpanAPIObjects.Approval> approvals = new List<OneSpanAPIObjects.Approval>();
approvals.add(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
Reply to: Getting error while calling sdk.createDocuments(packageId, document, doc)
Tuesday, March 22, 2022 at 12:21amHi 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.
-Pranay