matheusdelecrode

Is it possible to send multiple documents with metadata?

0 votes

Hello, I need to send multiple documents, I saw this post: https://community.onespan.com/forum/adding-multiple-documents-meta-data And in this post it informs that it would not be possible, but it is from 2018, is there any current solution for this?

 

This is the payload I'm using:

{
"roles": [
{
"id": "Role1",
"signers": [
{
"email": "[email protected]",
"firstName": "Example",
"lastName": "Example",
"company": "OneSpan Sign"
}
]
},
{
"id": "Role2",
"signers": [
{
"email": "[email protected]",
"firstName": "Example",
"lastName": "Example",
"company": "OneSpan Sign"
}
]
},
{
"id": "Role3",
"signers": [
{
"email": "[email protected]",
"firstName": "Example",
"lastName": "Example",
"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": 100,
"subtype": "FULLNAME",
"height": 50,
"left": 100,
"width": 200,
"type": "SIGNATURE"
}
]
}

],
"name": "Teste"
}
],
"name": "Teste",
"type": "PACKAGE",
"language": "en",
"emailMessage": "",
"description": "Esse é um teste para a aplicação",
"autocomplete": True,
"status": "DRAFT"
}
)


Approved Answer

Reply to: Is it possible to send multiple documents with metadata?

1 votes

Hi Matheus,

 

Try with the attached code base.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Attachments

Reply to: Is it possible to send multiple documents with metadata?

0 votes

Hi Matheus,

 

Please disregard the information in the post you referred to, it's possible to send multiple documents in a single call. Try with the attached example JSON where I added multiple JSON nodes under "documents", and add the corresponding "file" binary in the form-data (see the screenshot).

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Attachments

Reply to: Is it possible to send multiple documents with metadata?

0 votes

I need to send via python, but the request is returning 500,

I am sending this way:

files = {
"document1": ("file1.pdf", open("doc1.pdf", "rb").read(), 'application/pdf'),
"document2": ("file2.pdf", open("doc2.pdf", "rb").read(), 'application/pdf'),
}

data = {"Payload": json.dumps(
{"roles": [
{"id": "Role1", "signers": [
{"email": "[email protected]", "firstName": "Matheus", "lastName": "teste", "company": "JumpLabel"}
]
},
{"id": "Role2", "signers": [{"email": "[email protected]", "firstName": "Matheus ", "lastName": "teste", "company": "Jump"}]}],
"documents": [
{"approvals": [
{"role": "Role1", "fields": [
{"page": 0, "top": 0, "subtype": "FULLNAME", "height": 50, "left": 0, "width": 200, "type": "SIGNATURE"}]}],
"name": "document1.pdf", "id": 51},
{"approvals": [{"role": "Role2", "fields": [
{"page": 0, "top": 0, "subtype": "FULLNAME", "height": 50, "left": 0, "width": 200, "type": "SIGNATURE"}]}],
"name": "document1.pdf", "id": 51}],
"name": "Teste", "type": "PACKAGE", "language": "en", "emailMessage": "Segue para assinatura o acordo de serviço.", "description": "Envio de documento para assinatura", "autocomplete": True, "status": "DRAFT"}
)}

headers = {
'authorization': "api key",
'Content-Type': 'multipart/form-data'
}

response = requests.post(url, files=files, data=data, headers=headers)

 

in requests, sending as files=files and payload data=data?
 


Reply to: Is it possible to send multiple documents with metadata?

0 votes

Hi Matheus,

 

Few things:
(1)Set the form-data name as "file" for both files. They will match the metadata in sequence.

files = {
"file": ("file1.pdf", open("doc1.pdf", "rb").read(), 'application/pdf'),
"file": ("file2.pdf", open("doc2.pdf", "rb").read(), 'application/pdf'),
}

(2)In metadata, "documents" need to have unique id. Now both documents have id of "51".

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Is it possible to send multiple documents with metadata?

0 votes

I got the return <Response [500]>

I changed the ids, and the file dictionary:


files = {
"file": ("file1.pdf", open("doc1.pdf", "rb").read(), 'application/pdf'),
"file": ("file2.pdf", open("doc2.pdf", "rb").read(), 'application/pdf')
}

data = {"Payload": json.dumps(
{"roles": [
{"id": "Role1", "signers": [
{"email": "[email protected]", "firstName": "Matheus", "lastName": "Teste", "company": "JumpLabel"}
]
},
{"id": "Role2", "signers": [{"email": "[email protected]", "firstName": "Matheus ", "lastName": "Teste", "company": "Jump"}]}],
"documents": [
{"approvals": [
{"role": "Role1", "fields": [
{"page": 0, "top": 0, "subtype": "FULLNAME", "height": 50, "left": 0, "width": 200, "type": "SIGNATURE"}]}],
"name": "document1.pdf", "id": 50},
{"approvals": [{"role": "Role2", "fields": [
{"page": 0, "top": 0, "subtype": "FULLNAME", "height": 50, "left": 0, "width": 200, "type": "SIGNATURE"}]}],
"name": "documen2.pdf", "id": 51}],
"name": "Teste", "type": "PACKAGE", "language": "en", "emailMessage": "Segue para assinatura o acordo de serviço.", "description": "Envio de documento para assinatura", "autocomplete": True, "status": "DRAFT"}
)}

headers = {
'authorization': "api key",
'Content-Type': 'multipart/form-data'
}

response = requests.post(url, files=files, data=data, headers=headers) is this part correct?

 


Reply to: Is it possible to send multiple documents with metadata?

0 votes

Hi Matheus,

 

I think I found the issue - remove the 'Content-Type': 'multipart/form-data' from your headers, it will override/remove your request boundary.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Is it possible to send multiple documents with metadata?

0 votes

headers = {
'authorization': "Basic api_key"
}

 

I removed it, but now the return is now: <Response [400]>


Reply to: Is it possible to send multiple documents with metadata?

0 votes

Thank you Duo Liang, it worked!!


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