nhill40 | Posts: 40

Uploading multiple documents simultaneously using "files[]"

0 votes
Hi, I am attempting to create a package with multiple documents using the "files[]" multipart form field, but I always get back this message: { "messageKey": "error.validation.package.wrongNumberOfFiles", "technical": "Number of uploaded files does not match number of documents specified in package.", "message": "Number of uploaded files does not match number of documents specified in package.", "code": 400, "name": "Validation Error" } This has led me to dig into the package JSON and I can't seem to figure out how the items in the "documents" JSON collection are supposed to correlate to the files themselves. For example, if I am creating a new package with "file1.pdf" and "file2.pdf", how does eSignLive know which metadata entry within the "documents" JSON collection goes with each file?

mwilliams | Posts: 957

Reply to: Uploading multiple documents simultaneously using "files[]"

0 votes
Hey nhill40, I've not tried using name=files[], but I've had success with the setup of the multipart/form-data like:
-----boundary--------
name="file"; filename="somefilename.pdf"
file1
-----boundary--------
name="file"; filename="someotherfilename.pdf"
file2
-----boundary--------
name="payload"
JSON payload with documents in the documents portion of the payload in the order they're passed above.
-----boundary----------
I can test out files[], if you'd like and let you know what I find. Let me know!

nhill40 | Posts: 40

Reply to: Uploading multiple documents simultaneously using "files[]"

0 votes
Well, that was a lot easier than I was trying to make it! :D Indeed, it looks like it is just down to order. And "file" (rather than "files[]") worked just fine. Here is a cURL output of the (bare bones) test I created in Postman: curl -X POST \ https://sandbox.esignlive.com/api/packages \ -H 'authorization: Basic >' \ -H 'cache-control: no-cache' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -H 'postman-token: 8617b274-e380-33cd-d56f-120536b4fc04' \ -F file=@/Users/hilln/Downloads/pdf-sample.pdf \ -F file=@/Users/hilln/Downloads/pdf-sample.pdf \ -F 'payload={ "status": "DRAFT", "documents": [ { "name": "First File" }, { "name": "Second File" } ] }' Thanks for the help!

mwilliams | Posts: 957

Reply to: Uploading multiple documents simultaneously using "files[]"

0 votes
Great! Glad to help! :)

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