I'm trying to upload a transient document file to Adobe Sign in C#, and it has driven me to my wits end trying to get it to work.
I've even contacted Adobe, and even they don't know how to do it.
My code is as follows:
if (!File.Exists(@"documents\1-Registration Form.pdf"))
{
return;
}
Models objGetData = new Models();
RestClient objClient = new RestClient("https://api.na1.echosign.com:443/api/rest/v5");
RestRequest objRequest = new RestRequest("transientDocuments", Method.POST);
objRequest.AddFile("file", File.ReadAllBytes(@"documents\1-Registration Form.pdf"), "1-Registration Form.pdf");
objRequest.AddHeader("Access-Token", "-My Token Here-");
objRequest.RequestFormat = DataFormat.Json;
IRestResponse objResponse = objClient.Execute(objRequest);
var content = objResponse.Content;
JObject jsonLinq = JObject.Parse(content);
try
{
var objResultObjects = AllData(jsonLinq).First(c => c.Type == JTokenType.Array && c.Path.Contains("libraryDocumentList")).Children<JObject>();
}
catch(Exception ex)
{
ex.LogExceptionToDatabase();
}
return;
Here's the response that I'm getting as the result of my most recent attempt:
"{\"code\":\"NOT_FOUND\",\"message\":\"Resource not found\"}"
I typically get Bad request saying the file isn't present or a not found error, but they're not always the same.
All help will be appreciated.
EDIT:
The following code will give a response with a list of library docs so I know it's not the URL.
var objGetData = new Models();
var objClient = new RestClient("https://api.na1.echosign.com:443/api/rest/v5");
var objRequest = new RestRequest("libraryDocuments", Method.GET);
objRequest.AddHeader("Access-Token", "- My Key -");
objRequest.RequestFormat = DataFormat.Json;
objRequest.AddBody(objGetData);
IRestResponse objResponse = objClient.Execute(objRequest);
var content = objResponse.Content;
JObject jsonLinq = JObject.Parse(content);
SOLUTION:
var objClient = new RestClient(@"https://api.na1.echosign.com:443/api/rest/v5/");
var objRequest = new RestRequest(@"transientDocuments", Method.POST);
var thisFile = File.ReadAllBytes( @"documents\1-Registration Form.pdf");
objRequest.AddFile("File", File.ReadAllBytes( @"documents\1-Registration Form.pdf"), "1-Registration Form.pdf");
objRequest.AddHeader("Access-Token", "-MyToken-");
objRequest.RequestFormat = DataFormat.Json;
IRestResponse objResponse = objClient.Execute(objRequest);
var content = objResponse.Content;
JObject jsonLinq = JObject.Parse(content);