I am trying to make a POST request to the Adobe /transientDocuments REST API with a pdf file attached, in order to retrieve the transientDocumentID back for use with other Adobe Acrobat Sign services.
I have successfully managed to implement the Oauth flow which returns me a valid bearer token which according to my understanding, I can use to query the transientDocuments endpoint. So, I have built a method that takes in a pdf file as input to achieve this, but I am getting a 403 forbidden error when trying to complete the request. And when I debug the method and use the bearer token I receive there in the Acrobat Sign REST API Version 6 Methods here: https://secure.na4.adobesign.com/public/docs/restapi/v6#!/transientDocuments/createTransient, the request works successfully. So, I am not sure if it is perhaps an issue with how I am adding the file in as form data or if there might be a complication on the configuration side in my Adobe application settings, I have allowed all scopes there so not sure what else the issue could be.
This is the C# code I am using to perform the POST method:
public static string UploadTransientDocument(FileData data, string code)
{
string token = adobeOuath(code);
string base64;
string fileName = ContentDispositionHeaderValue.Parse(data.file.ContentDisposition).FileName.Trim('"');
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
using (var ms = new MemoryStream())
{
data.file.CopyTo(ms);
var fileBytes = ms.ToArray();
base64 = Convert.ToBase64String(fileBytes);
}
var bytes = Convert.FromBase64String(base64);
var contents = new StreamContent(new MemoryStream(bytes));
var formContent = new MultipartFormDataContent();
formContent.Add(contents, "File", fileName);
var response = client.PostAsync(https://api.echosign.com/api/rest/v6/transientDocuments, formContent);
var responseBody = response.Result.ToString();
return responseBody;
}
Any assistance would be appreciated.