Adding document to package gives error
Friday, August 10, 2018 at 10:31amHello,
I'm trying to integreate my Ruby on Rails application with OneSpan.
I was able to create a package but when I try to add a document to that package I get Unexpected Content-Disposition value for parameter 'name'".
I used PostMan and here is the code for Request:
POST /api/packages/fcsS1bBSu37ETcAXYmVLvM1S4bg=/documents HTTP/1.1 Host: sandbox.esignlive.com Authorization: Basic xxxxxxxxxxxxxx Cache-Control: no-cache Postman-Token: 752f5f9d-64a1-188c-0ad2-f29d01843563 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="N11.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW--Response:
{
"messageKey": "error.validation.invalidParameters",
"technical": "Unexpected Content-Disposition value for parameter 'name'",
"message": "Invalid parameters.",
"code": 400,
"name": "Validation Error"
}
What am I missing?
My code
def self.add_file_to_package(package_id, file, file_name)
begin
url = "#{ENV["ONE_SPAN_URL"]}/packages/#{package_id}/documents"
response = RestClient.post(url, {:file => File.new(file, 'rb')}, {Authorization: "Basic #{ENV["ONE_SPAN_KEY"]}"})
return response.body
rescue RestClient::Exception => err
Rails.logger.info err.response
raise
end
end
Reply to: Adding document to package gives error
Friday, August 10, 2018 at 12:11pm{ "name":"sampleAgreement", "index":0, "approvals":[ { "fields":[ { "type":"SIGNATURE", "subtype":"FULLNAME", "width":200.0, "height":50.0, "left":550.0, "page":0, "top":165.0, "extract":false } ], "role":"your role id" } ] }And if you are uploading multiple documents, your payload JSON should organize like below:[ { "name":"document1", .... }, { "name":"document2", .... } ]Hope this could help you! DuoReply to: Adding document to package gives error
Tuesday, August 14, 2018 at 04:59amdef self.add_file_to_package(package_id, file, file_name) begin url = "#{ENV["ONE_SPAN_URL"]}/packages/#{package_id}/documents" response = RestClient.post(url, {:file => File.new(file, 'rb'), 'payload':{"name":"test"}.to_json}, {Authorization: "Basic #{ENV["ONE_SPAN_KEY"]}"}) return response.body rescue RestClient::Exception => err Rails.logger.info err.response raise end endReply to: Adding document to package gives error
Tuesday, August 14, 2018 at 05:15am