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

400 Errors in /transientDocuments POSTS

Community Beginner ,
Apr 16, 2020 Apr 16, 2020

Copy link to clipboard

Copied

Hello All,

I'm working on my first Adobe Sign integration and I'm running into a sumbling block right off the bat.

I'm calling the /transientDocuments API and I keep getting a 400 Error or 415 error.

I'm coding in C# and using a WebClient to try to upload a document (the ultimate goal is to send an agreement to an end user).

 

Here is a snippet of code that throws a 400 error exception:

using(WebClient wc = new WebClient())
{

wc.Headers[HttpRequestHeader.Authorization] = string.Format("{0} {1}", accessToken.token_type, accessToken.access_token);
wc.Headers.Add("Content-Disposition", "form-data; name=\";File\";filename=\"" + model.EvalData.FileName + "\")");
wc.Headers.Add("Mime-Type", "application/pdf");
byte[] bResults = wc.UploadFile(endPoint, tempFileName);

}

 

I get this response:

Metadata
x-request-id : 53e8adb9-705f-441c-b2f5-8b6d0f651dd0
content-type : application/json
status : 400

Body
{
     "code": "NO_FILE_CONTENT",
     "message": "Must provide file body"
}

 

I've tried other variations of this code but keep getting the 400 or 415 errors.

Can someone please point out what I'm doing wrong here?

 

Thanks in advance,

-tomas

TOPICS
SDK

Views

1.7K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Beginner , Apr 23, 2020 Apr 23, 2020

Solved this by using the RestSharp library.

But beware, the field name for uploaded document must be "File" and is CASE SENSITIVE.

This is not mentioned in the Docs and wasted 2 days of time for me. So you are WARNED.

-tomas

Votes

Translate

Translate
New Here ,
Apr 16, 2020 Apr 16, 2020

Copy link to clipboard

Copied

Hey,
You must upload a file/ provide a file that's what you are missing. 

Votes

Translate

Translate

Report

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
Community Beginner ,
Apr 17, 2020 Apr 17, 2020

Copy link to clipboard

Copied

Hey,

If you look at my code snippet, you will notice this line:

byte[] bResults = wc.UploadFile(endPoint, tempFileName);

 

This is the line at which my file is uploaded to the other endpoint.

I am sending a file. I have also uploaded it as a byte stream and I receive a 415 error (media type not supported).


Any other ideas?

Thanks,

-tomas

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Apr 23, 2020 Apr 23, 2020

Copy link to clipboard

Copied

Solved this by using the RestSharp library.

But beware, the field name for uploaded document must be "File" and is CASE SENSITIVE.

This is not mentioned in the Docs and wasted 2 days of time for me. So you are WARNED.

-tomas

Votes

Translate

Translate

Report

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
New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

LATEST

You are the man.  I can't believe calling it "file" vs "File" was the issue for me.  I've spent two days trying to get this working.

Votes

Translate

Translate

Report

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
New Here ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

Can you provide a code snippet of the request. I have been trying to get this to work for 3 days. Thank you.

Votes

Translate

Translate

Report

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
New Here ,
Apr 27, 2022 Apr 27, 2022

Copy link to clipboard

Copied

I hope you figured this out - it is indeed quite a very finnicky API. I am not OP, but here was my solution using RestSharp:

var client = new RestClient(_api_endpoint);
var request = new RestRequest("transientDocuments", RestSharp.Method.Post);

//Add auth token to header
request.AddHeader("Authorization", $"Bearer {auth_token}");

request.AddFile("File", "Form.pdf");  //Naming the file 'File' is VITAL for the API... for some reason
request.AlwaysMultipartFormData = true;

RestResponse response = await client.ExecuteAsync(request);

dynamic content = JsonConvert.DeserializeObject(response.Content);

String transientDocumentId = content.transientDocumentId;

 

Votes

Translate

Translate

Report

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