Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4807

FedEx REST API - Upload Document error (multipart stream ended)

$
0
0

I am testing the FedEx REST API via Python. I am able to perform the authentication and e.g. validate a shipment - however, I am unable to perform an Upload Documents POST request. The official FedEx docs unfortunately seem to lack a correct example for this (as of 21.02.2023)

My code is below:

url = "https://documentapitest.prod.fedex.com/sandbox/documents/v1/etds/upload"f = open("file.txt", "rb")text_data = f.read()f.close()headers = {"Content-Type": "multipart/form-data","x-customer-transaction-id": "12XXXXXX","Authorization": f"Bearer {access_token}",}response = requests.post(    url,    files=dict(        document='{"workflowName":"ETDPreshipment","name":"file.txt","contentType":"text/plain","meta":{"shipDocumentType":"COMMERCIAL_INVOICE","originCountryCode":"DK","destinationCountryCode":"BE"}',        attachment=("file.txt", text_data, "text/plain")    ),    headers=headers,)print(response.text)

I get an error code 503 with the response.text providing the following error:

 {  "customerTransactionId": "12XXXXXX","errors":[           {  "code":"SERVICE.NOT.AVAILABLE","message":"Enterprise Document Upload Service Unavailable"         }      ]}

I am unsure if this indicates an error in my script, or if the 'Upload Documents' API is only supported for production environments?


Viewing all articles
Browse latest Browse all 4807

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>