Package with one attachment reveive error 406 Not acceptable
Friday, February 12, 2021 at 08:24amHello,
I am trying to interface with OneSpan Sign using the REST API. I am using the LotusScript language on a HCL Notes / Domino platform.
When I send a package with no document, including only the json, it works fine. When I try to add a document using a MIME message, I always get the 406 Not Acceptable error message. I did some research in the forums but couldn't find any helpful help for this error.
HTTP request:
' --- open a new POST request and set the Content-type header
Set objHttp = CreateObject("Microsoft.XMLHTTP")
objHttp.open "POST", "https://sandbox.esignlive.com/api/packages", False
objHttp.setRequestHeader "Content-Type", "multipart/form-data; boundary=SDSP----------BY5SFF"
objHttp.setRequestHeader "Accept", "text/html"
objHttp.setRequestHeader "Authorization", "Basic MYINTEGRATORKEY"
objHttp.send(RequestPayload)
Request payload:
--SDSP----------BY5SFF
Content-Disposition: form-data; name="file"; filename="Document TEST.pdf"
Content-Type: application/pdf
%PDF-1.5
<PDF document>
%%EOF
--SDSP----------BY5SFF
Content-Disposition: form-data; name="payload"
Content-Type: application/json
{
"name": "Test PBE 2021-02-11 15:50:13",
"type": "PACKAGE",
"language": "fr",
"emailMessage": "Veuillez signer le contrat ci-joint dans les plus bref délais.",
"description": "Test PBE 2021-02-11 15:50:13",
"autoComplete": true,
"roles": [{
"id": "1",
"signers": [{
"email": "[email protected]",
"firstName": "Emma",
"lastName": "Smith",
"company": "Company"
}]
}, {
"id": "3",
"signers": [{
"email": "[email protected]",
"firstName": "Mark",
"lastName": "Smith"
}]
}],
"status": "DRAFT"
}
--SDSP----------BY5SFF--
Response payload:
{"messageKey":"http.status.406","message":"Not Acceptable","code":406,"name":"Not Acceptable"}
Thank you for your help,
Patrick B.
Reply to: Package with one attachment reveive error 406 Not acceptable
Friday, February 12, 2021 at 08:54amHi Patrick,
For the first glance, I saw you were specifying the Accept as text/html (objHttp.setRequestHeader "Accept", "text/html"), which is the response type for another API endpoint for uploading documents to an existing package "POST /api/packages/{packageId}/documents".
Could you try with "Accept: application/json" instead and see if this solves the error?
Duo
Reply to: Package with one attachment reveive error 406 Not acceptable
Friday, February 12, 2021 at 09:01amHello Duo,
I already tried that. When I put application/json in the header I receive error 500.
<html><head><title>Error</title></head><body>Internal Server Error</body></html>
Patrick B.
Reply to: Package with one attachment reveive error 406 Not acceptable
Friday, February 12, 2021 at 09:49amHi Patrick,
#1 I believe you still need to accept application/json as response type, since it's documented as per the Swagger file.
#2 From your JSON, it seems you are not adding the "documents" array, it's a must that you include both the metadata - document ID, Name, etc, and the binary file data, so that OneSpan Sign system knows how to match them.
You can use the same example JSON as the Quick Start Guide did, with two signers and one document.
{
"roles":[
{
"id":"Role1",
"signers":[
{
"email":"[email protected]",
"firstName":"1.firstname",
"lastName":"1.lastname",
"company":"OneSpan Sign"
}
]
},
{
"id":"Role2",
"signers":[
{
"email":"[email protected]",
"firstName":"2.firstname",
"lastName":"2.lastname",
"company":"OneSpan Sign"
}
]
}
],
"documents":[
{
"approvals":[
{
"role":"Role1",
"fields":[
{
"page":0,
"top":100,
"subtype":"FULLNAME",
"height":50,
"left":100,
"width":200,
"type":"SIGNATURE"
}
]
},
{
"role":"Role2",
"fields":[
{
"page":0,
"top":300,
"subtype":"FULLNAME",
"height":50,
"left":100,
"width":200,
"type":"SIGNATURE"
}
]
}
],
"name":"Test Document"
}
],
"name":"Example Package",
"type":"PACKAGE",
"language":"en",
"emailMessage":"",
"description":"New Package",
"autocomplete":true,
"status":"SENT"
}
#3 The 500 error was replied in html format, so I am wondering if it's replied from OSS server (normally it's in JSON format). Not sure it's because the JSON lacks the "documents" node, or caused by other reasons.
Duo
Reply to: Package with one attachment reveive error 406 Not acceptable
Friday, February 12, 2021 at 02:57pmHello Duo,
I changed the JSON to add the documents array. I also removed a signer to make it simpler. When I send the new JSON by itself (not a MIME package), the JSON is accepted and the package is created.
{
"name": "Test PBE 2021-02-12 15:41:07",
"type": "PACKAGE",
"language": "fr",
"emailMessage": "Veuillez signer le contrat ci-joint dans les plus bref délais.",
"description": "Test PBE 2021-02-12 15:41:07",
"autoComplete": true,
"roles": [{
"id": "1",
"signers": [{
"email": "[email protected]",
"firstName": "Emmanuelle",
"lastName": "Smith",
"company": "Company Inc."
}]
}],
"documents": [{
"approvals": [{
"role": "1",
"fields": [{
"page": "0",
"top": "100",
"subtype": "FULLNAME",
"height": "50",
"left": "100",
"width": "200",
"type": "SIGNATURE"
}]
}],
"name": "Test Document"
}],
"status": "DRAFT"
}
When I include the PDF file with the new JSON in a MIME package, I get error 500 again. Could it be a problem with my MIME formating? I attached a text file with the entire MIME package.
Thanks again,
Patrick B.
Reply to: Package with one attachment reveive error 406 Not acceptable
Friday, February 12, 2021 at 04:52pmHi Patrick,
Thanks for the sharing! Could you try to add an extra blank line before and after the JSON?
--SDSP----------BY5SFF
Content-Disposition: form-data; name="payload"
Content-Type: application/json
{"name":"Test PBE 2021-02-11 15:50:13","type":"PACKAGE","language":"fr","emailMessage":"Veuillez signer le contrat ci-joint dans les plus bref délais.","description":"Test PBE 2021-02-11 15:50:13","autoComplete":true,"roles":[{"id":"1","signers":[{"email":"[email protected]","firstName":"Emma","lastName":"Smith","company":"Company"}]},{"id":"3","signers":[{"email":"[email protected]","firstName":"Mark","lastName":"Smith"}]}],"status":"DRAFT"}
--SDSP----------BY5SFF--
Seems I can reproduce the same 500 error if I removed them.
Duo
Reply to: Package with one attachment reveive error 406 Not acceptable
Monday, February 15, 2021 at 11:09amHello Duo,
Adding a blank line before the JSON code fixed error 500. But now I receive a error 400.
{"messageKey":"error.validation.documentPreVerifyInvalidResponseNumberError","parameters":{"errorException":"number of documents that need verification = 2, number of verification results = 0"},"message":"The number of Pre-Verify results does not match the number of documents that were sent for verification.","code":400,"name":"Validation Error"}
I do not see in the JSON or the MIME message where I indicate that there are two documents to verify. I am using this guide as a reference (JAVA Rest):
https://community.onespan.com/documentation/onespan-sign/guides/quick-start-guides/developer/creating-and-sending-transaction
Here is my payload:
{
"roles": [{
"id": "Role1",
"signers": [{
"email": "[email protected]",
"firstName": "Emmanuelle",
"lastName": "Smith",
"company": "Company Inc."
}]
}],
"documents": [{
"approvals": [{
"role": "Role1",
"fields": [{
"page": "0",
"top": "100",
"subtype": "FULLNAME",
"height": "50",
"left": "100",
"width": "200",
"type": "SIGNATURE"
}]
}],
"name": "Test Document"
}],
"name": "Test PBE 2021-02-15 12:01:02",
"type": "PACKAGE",
"language": "fr",
"emailMessage": "Veuillez signer le contrat ci-joint dans les plus bref délais.",
"description": "Test PBE 2021-02-15 12:01:02",
"autoComplete": true,
"status": "DRAFT"
}
As you can see, I made it almost identical than the one in the guide.
Thanks again,
Patrick B.
Reply to: Package with one attachment reveive error 406 Not acceptable
Monday, February 15, 2021 at 11:29amHi Patrick,
After checking with internal documents, this error "The number of Pre-Verify results does not match the number of documents that were sent for verification." might be related to uploading not properly tagged document to the ADA package.
I didn't see you specified "settings" > "ceremony" > "ada": true in your payload, but could you also share your account email to [email protected] so that I can help you check if the setting was turned on at account level? Also, if there's no sensitive information containing in the PDF, could you also share the PDF to above email?
Duo