Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Getting error 403 Forbidden when trying to post to /transientDocuments REST API

New Here ,
Apr 04, 2023 Apr 04, 2023

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. But when I debug the method and use the bearer token I have there in the Adobe swagger documentation here: https://secure.na4.adobesign.com/public/docs/restapi/v6#!/transientDocuments/createTransientDocument , 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 to the Upload Transient Documents REST API:

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;
        }
TOPICS
Send documents
588
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation