AnsweredAssumed Answered

Uploading a file to a REST policy using curl

Question asked by richiethom on Dec 8, 2017
Latest reply on Aug 24, 2018 by Wildcatz

I am trying to develop a policy that accepts a file sent from curl. As far as I can tell the following curl command is correct:


curl -d @file.xml http://myapigateway:8080/resttest


On the API Gateway, I have the following simple policy with a single assertion:


"Return Template Response to Requestor" with a content type of text/json; charset=UTF-8 and a body of {"status":"ok"}


Enabling the debugger shows that request.mainpart is null when I try to send a file of about 4.5 megabytes. If I send a file of 1 megabyte, request.mainpart contains the contents of the file.


The headers sent by curl are:

  • "accept:*/*"
  • "content-length:4731313"
  • "content-type:application/x-www-form-urlencoded"
  • "expect:100-continue"
  • "host:myapigateway:8080"
  • "user-agent:curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"


What is the correct way to allow a REST request to a policy on the API Gateway to upload a file in this way? I assume the API Gateway is able to accept larger files?


I'm using curl 7.19.7 and API Gateway 8.4