Apex SDK - Receiving Error "message":"Invalid parameters.","code":400,"name":"Validation Error"
Thursday, June 22, 2023 at 08:14amWe were successfully sending transactions and documents to OneSpan until the start of this week when we started receiving the below error. I have also put the invoking code below, it is based on the Apex SDK. It's a weird error as this was working on Friday..
CallOut:
HttpRequest[
Endpoint=https://sandbox.esignlive.com/api/packages/2c-NU-6SlNqyIhDT2Uhew9hueus=/documents, Method=POST
]
Error in Full Text:
OneSpanRESTAPIHelper.OneSpanRestAPIHelperException: Error creating OneSpan package with documents: 400 - Bad Request - {"technical":"Unexpected Content-Disposition value for parameter 'name'","messageKey":"error.validation.invalidParameters","message":"Invalid parameters.","code":400,"name":"Validation Error"}
Invoking Code:
OneSpanSDK sdk = new OneSpanSDK();
OneSpanAPIObjects.Package_x pkg = new OneSpanAPIObjects.Package_x();
pkg.name = 'Test Subject ' + DateTime.Now();
String packageId = sdk.createPackage(pkg);
Cust_Object__c dsRec = [SELECT Id FROM Cust_Object__c WHERE Id = :dsId LIMIT 1];// Gets the document
// Create Documents for Transaction
Attachment att = [Select Id, Name, Body, ParentId From Attachment Where ParentId = :dsId];
Map<String,Blob> doc = new Map<String,Blob>();
doc.put('Sample Document', att.Body);
OneSpanAPIObjects.Document document = new OneSpanAPIObjects.Document();
document.name = att.Name;
document.id = 'document1';
String resp = sdk.createDocuments(packageId, document, doc);
Reply to: Apex SDK - Receiving Error "message":"Invalid parameters.","code":400,"name":"Validation Error"
Thursday, June 22, 2023 at 09:11amHi Charles,
I've seen the same error in a few recent cases(case1, case2) when using APEX sdk function sdk.createDocuments(packageId, document, doc);
A quick question, what's the file type of your attachment body? It might the cause of issue if it's not a PDF file when you use .createDocuments() method.
Duo
Reply to: Apex SDK - Receiving Error "message":"Invalid parameters.","code":400,"name":"Validation Error"
Thursday, June 22, 2023 at 10:12amHi Duo,
We were using a .docx file, but when I converted it to a pdf and re-attached it, that appears to have solved it!
Thank you so much for your assistance!