How to use Python Requests to make this POST request
<p>I'm trying to POST to the Adobe Sign API. Even if you're not familiar with the API, this should be a pretty straightforward question. </p>

<p>Sign's documentation says the POST I need to do looks like this: </p>

<pre><code>POST /api/rest/v5/transientDocuments HTTP/1.1
Host: api.na1.echosign.com
Access-Token: MvyABjNotARealTokenHkYyi
Content-Type: multipart/form-data
Content-Disposition: form-data; name="File"; filename="MyPDF.pdf"

&lt;PDF CONTENT&gt;
</code></pre>

<p>Here is my current code, using Python Requests: </p>

<pre><code>def createTransientDocument(your_file_base_url, file_name):
    headers = {'access-token': datafile.accessToken,
               'x-user-email': '&lt;redacted for StackOverflow&gt;',
               'content-type': 'multipart/form-data'}

    files = {'file': (file_name, open(your_file_base_url + file_name, 'rb'))}

    r = requests.post(datafile.transient_documents_URL, files = files, headers=headers)

    return r
</code></pre>

<p>Unfortunately, this is not quite what the API is looking for. I get a response: </p>

<pre><code>*{"code":"BAD_REQUEST","message":"The request provided is invalid"}*
</code></pre>

<p>Any tips on how to use the Requests library to POST my PDF file to this API? </p>

<p>Sorry for the n00b question, but I am learning the Requests library right now. Thanks. </p>

<p>It's a nuance, but you need to name the file "File" with a capital F. Otherwise the API doesn't pick it up on the Adobe Sign side. Here is the correct (and working) API call. </p>

<pre><code>def createTransientDocument(your_file_base_url, file_name):
    headers = {'access-token': datafile.accessToken,
               'x-user-email': '&lt;email redacted&gt;',
               'content-disposition':'form-data'}

    files = {'File': open(your_file_base_url+file_name, 'rb')}


    r = requests.post(datafile.transient_documents_URL, files=files, headers=headers)

    return r
</code></pre>

python post python-requests