title: Python flask: forward POST to external API
body: <p>I am building a microservice for the Camunda rest API using python flask and flask_restplus, python 3.7.0. Camunda is running in a docker container, available via localhost, port 8080. All GET requests to my microservice are being forwarded to the Camunda API via redirect, which is working perfectly fine.</p>
  
  <p>POST requests (tested via postman, as suggested in the official tutorial) are not being forwarded properly using</p>
  
  <p><code>redirect(camunda_api_url)</code>
  or 
  <code>request.post(camunda_api_url)</code></p>
  
  <p>The POST request via postman is done using</p>
  
  <pre><code>    Header: Content-Type: multipart/form-data
      Body: upload File Object (somefile.bpmn)
  </code></pre>
  
  <p>When I do the POST to the Camunda REST-API directly, everything works just fine, but when I try to redirect my post via my microservice, I get status code 200, but the file isn't being uploaded.</p>
  
  <p>Debugging at my endpoint I can see that the file is being received:</p>
  
  <pre><code>    print(request.files['upload'])
      &lt;FileStorage: 'somefile.bpmn' ('application/octet-stream')&gt;
  </code></pre>
  
  <p>Thus the file is being transmitted successfully, but the redirect doesn't work.</p>
  
  <p>My endpoint method looks like this:</p>
  
  <pre><code>    def post(self):
          print(request.files['upload'])
          test = requests.post(host_prefix + 'deployment/create', files=request.files)
          print(test.status_code)
  </code></pre>
  
  <p>Modifying the request.post via</p>
  
  <pre><code>    data=request.files
      data=request.files['upload']
      or omiting data completely
  </code></pre>
  
  <p>always results in the file not being uploaded.</p>
  
  <p>Trying redirect via</p>
  
  <p><code>redirect(host_prefix + 'deployment/create', code=307)</code></p>
  
  <p>also results in the file not being uploaded.</p>
  
  <p>How can I redirect this post request properly to the Camunda API ?
  This is not a question about the Camunda API rather than how to redirect a POST request to a foreign endpoint properly.</p>
  
  <p>P.S.: I created my api and endpoints like this:</p>
  
  <pre><code>    app = Flask(__name__)
      api = Api(app, version='0.1', title='BPMN-API', description='A BPMN-API for Camunda, implemented in python')
      ...
      api.add_resource(CreateDeployment,   api_prefix +  'deployment/create', methods=['POST'])
  </code></pre>