Amanda Lemmons Posted May 27, 2020 Share Posted May 27, 2020 Hi, I am using the RightSignature API and my doucment_template_is returning nil. These are the steps I take: 1. I make POST call to the send_requests uri and then do a PUT call to the upload_url uri_str ="https://api.rightsignature.com/public/v1/sending_requests" uri = URI.parse uri_str puts uri body_data = { "file": { "name": "Initial_Disclosure_Documents.pdf", "source": "upload" }, "document": { "signer_sequencing": false, "expires_in": 30, "name": "Initial Disclosure Document", "callback_url": "https:/xxx/rightsignature/webhooks", "roles": [ { "name": "a", "signer_name": "#{creditor_name}", "signer_email": "#{creditor_email}" }, { "name": "b", "signer_name": "#{originator_name}", "signer_email": "#{originator_email}", "is_sender": true }, { "name": "c", "signer_name": "#{buyer_name}", "signer_email": "#{buyer_email}" }, { "name": "d", "signer_name": "#{co_buyer_name}", "signer_email": "#{co_buyer_email}" } ] }, "sending_request": {} } http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new uri.request_uri request["Authorization"] = "Basic #{token}" request["Content-Type"] = "application/json" request.body = body_data.to_json response = http.request request puts "#{response.code} #{response.message}" upload_url = "" document_id = "" if response.kind_of? Net::HTTPSuccess root = JSON.parse response.body upload_url = root["sending_request"]["upload_url"] document_id = root["sending_request"]["id"] end file_content = pdf uri = URI.parse upload_url http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Put.new uri.request_uri request.body = file_content response = http.request request puts response 2. I POST using the returned document_id from step 1 post_url = "https://api.rightsignature.com/public/v1/sending_requests/#{document_id}/uploaded" uri = URI.parse post_url http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new uri.request_uri request["Authorization"] = "Basic #{token}" response = http.request request 3. Make a GET request. This should return the document_template_id but it comes back as null get_uri_str ="https://api.rightsignature.com/public/v1/sending_requests/#{document_id}" uri = URI.parse get_uri_str http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new uri.request_uri request["Authorization"] = "Basic #{token}" current_response = http.request request json_response = JSON.parse(current_response.body) puts json_response document_template_id = json_response["document_template_id"] Here the json_reponse that I get after doing step 3 {"id"=>"043a81a3-1c7f-4401-a6ef-b97089222a00", "status"=>"downloading", "status_message"=>nil, "document_template_id"=>nil, "created_at"=>"2020-05-27T03:05:59.588-07:00", "updated_at"=>"2020-05-27T03:05:59.890-07:00"} The document does get sent out to the signers and it shows up in the RightSignature Dashboard. I also receive a response from the webhooks that does contain the document_template_id. {"callbackType":"Document","id":"ef252054-c2d9-4fc2-b564-24e121d24439","event":"created","documentState":"pending","status":"pending","createdAt":"2020-05-27T03:05:59.995-07:00"} If you could point me in the correct direction as to what I am doing wrong, that would be great. Thanks, Link to comment
0 Vikas Kumar1709162057 Posted May 27, 2020 Share Posted May 27, 2020 Hi Amanda, Can you let us know the "status" field from the response in step-1. Just the value of root["sending_request"]["status"] should be fine. Regards, Vikas Link to comment
0 Amanda Lemmons Posted May 27, 2020 Author Share Posted May 27, 2020 Hi Vikas, The response from step one is this: {"sending_request"=>{"id"=>"16bad697-b1e7-485c-8abd-44c0678acfcf", "status"=>"waiting_for_file", "status_message"=>nil, "upload_url"=>"https://rightsignature-sr-production.s3.amazonaws.com/XXXXXX", "document_template_id"=>nil, "created_at"=>"2020-05-27T08:05:49.670-07:00", "updated_at"=>"2020-05-27T08:05:49.670-07:00"}} Link to comment
0 Vikas Kumar1709162057 Posted May 28, 2020 Share Posted May 28, 2020 Hi Amanda, The code looks fine. I think you are checking the status way too early. You might have to poll for the sending_request status to be completed. Once it shows up as completed then you should check for the document_template_id in the same response. Let me know if you face any issues. Regards, Vikas Link to comment
Question
Amanda Lemmons
Hi,
I am using the RightSignature API and my doucment_template_is returning nil.
These are the steps I take:
1. I make POST call to the send_requests uri and then do a PUT call to the upload_url
uri_str ="https://api.rightsignature.com/public/v1/sending_requests" uri = URI.parse uri_str puts uri body_data = { "file": { "name": "Initial_Disclosure_Documents.pdf", "source": "upload" }, "document": { "signer_sequencing": false, "expires_in": 30, "name": "Initial Disclosure Document", "callback_url": "https:/xxx/rightsignature/webhooks", "roles": [ { "name": "a", "signer_name": "#{creditor_name}", "signer_email": "#{creditor_email}" }, { "name": "b", "signer_name": "#{originator_name}", "signer_email": "#{originator_email}", "is_sender": true }, { "name": "c", "signer_name": "#{buyer_name}", "signer_email": "#{buyer_email}" }, { "name": "d", "signer_name": "#{co_buyer_name}", "signer_email": "#{co_buyer_email}" } ] }, "sending_request": {} } http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new uri.request_uri request["Authorization"] = "Basic #{token}" request["Content-Type"] = "application/json" request.body = body_data.to_json response = http.request request puts "#{response.code} #{response.message}" upload_url = "" document_id = "" if response.kind_of? Net::HTTPSuccess root = JSON.parse response.body upload_url = root["sending_request"]["upload_url"] document_id = root["sending_request"]["id"] end file_content = pdf uri = URI.parse upload_url http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Put.new uri.request_uri request.body = file_content response = http.request request puts response
2. I POST using the returned document_id from step 1
post_url = "https://api.rightsignature.com/public/v1/sending_requests/#{document_id}/uploaded" uri = URI.parse post_url http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new uri.request_uri request["Authorization"] = "Basic #{token}" response = http.request request
3. Make a GET request. This should return the document_template_id but it comes back as null
get_uri_str ="https://api.rightsignature.com/public/v1/sending_requests/#{document_id}" uri = URI.parse get_uri_str http = Net::HTTP.new uri.host, uri.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new uri.request_uri request["Authorization"] = "Basic #{token}" current_response = http.request request json_response = JSON.parse(current_response.body) puts json_response document_template_id = json_response["document_template_id"]
Here the json_reponse that I get after doing step 3
{"id"=>"043a81a3-1c7f-4401-a6ef-b97089222a00", "status"=>"downloading", "status_message"=>nil, "document_template_id"=>nil, "created_at"=>"2020-05-27T03:05:59.588-07:00", "updated_at"=>"2020-05-27T03:05:59.890-07:00"}
The document does get sent out to the signers and it shows up in the RightSignature Dashboard. I also receive a response from the webhooks that does contain the document_template_id.
{"callbackType":"Document","id":"ef252054-c2d9-4fc2-b564-24e121d24439","event":"created","documentState":"pending","status":"pending","createdAt":"2020-05-27T03:05:59.995-07:00"}
If you could point me in the correct direction as to what I am doing wrong, that would be great.
Thanks,
Link to comment
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now