RightSig: Generated a doc ID, but do not understand how to make the PUT request to upload_url

  • 1
  • Question
  • Updated 3 weeks ago
I am using RightSignature API. I have successfully followed the steps to generate a doc ID, and then the instructions say "PUT to the upload_url returned in the Sending Request response to upload the Document base file, complete with Text Tags." How do I make this request to the upload_url? I see no examples that have appropriate explanations to answer my question and yes, I did look at the API docs. I am not using PHP, or similar. I am using ColdFusion. I have checked and noted that it does provide PUT request functionality with CFHTTP, so that appears to not be the problem. How can I do this properly? How does the file actually get sent to you? Can I do a binary read of the file or something of that nature, in my CFHTTP call to upload_url, in the request body? The error I am receiving is "Unable to determine MIME type of file." I am setting the MIME type as application/pdf in the request header, so I do not know why I receive this error. Thank you!!!

Photo of Stephanie Fischer

Stephanie Fischer

  • 7 Posts
  • 0 Reply Likes

Posted 4 weeks ago

  • 1
Photo of Saravanan Kannan

Saravanan Kannan, Employee

  • 32 Posts
  • 6 Reply Likes
Hi Stephanie,

I am assuming you have done the first step https://api.rightsignature.com/documentation/resources/v1/sending_requests/create.en.html and got a sending request id and upload url in the response. Then the step 2 will be to upload the PDF to the upload url. I am not sure about ColdFusion, but this is how it is done with php/curl.

Hope this gives you an idea:

// STEP 2
$ch = curl_init();
$sr_id = YOUR_SENDING_REQUEST_ID;
$upload_url = YOUR_UPLOAD_URL;

curl_setopt($ch, CURLOPT_URL, $upload_url);
curl_setopt($ch, CURLOPT_PUT, 1);
$file_path_str =YOUR FILE/DOCUMENT PATH;
$fh_res = fopen($file_path_str, 'r');
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/pdf"));
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path_str));

$response = curl_exec($ch);

$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo 'HTTP code: ' . $httpcode;

if (curl_errno($ch)) {
  print "Error: " . curl_error($ch);
}

fclose($fh_res);

Thanks
Saravanan
(Edited)
Photo of Stephanie Fischer

Stephanie Fischer

  • 7 Posts
  • 0 Reply Likes
Thank you for the response. Yes, I had properly done the first step and am at the point where this step is needed. I do not know PHP.... Is the code grabbing the binary data from the file and sending it? I will need an in English explanation. What params are being transmitted with what type of values? Thank you very much!
(Edited)
Photo of Saravanan Kannan

Saravanan Kannan, Employee

  • 32 Posts
  • 6 Reply Likes
Stephanie,

As I mentioned earlier, with the upload url you received in the response from the step 1, do a PUT request to that url.

I am not familiar with cold fusion, but you could try this:

setting the Content-Type in the header to 'application/pdf', also set the full path of the file/pdf in the file parameter.

Thanks
Saravanan
Photo of Stephanie Fischer

Stephanie Fischer

  • 7 Posts
  • 0 Reply Likes
Thank you very much. Yes, that was indeed the issue. It was because I was not specifying Content-Type properly.
(Edited)