Apache Camel - Split JSON array and call POST to the REST service iteratively
<p>I have a requirement of processing an Excel file and POST its contents to a REST service. I could load and convert Excel rows to a JSON array through Apache POI. However while POSTing to the REST service it fails with HTTP status 413 because POST body is too big due to the number of rows in the Excel file. </p>

<p>Is there a way in Apache Camel to can limit the JSON input size of a REST service and repetitively invoke the REST service call. Please help.</p>

<p>Below is the Java DSL route config.</p>

<pre><code>from("file:/excelfilelocation/inputexcel.xls")
        .bean(new ExcelConverter(), "processExcel") // Converts excel rows to ArrayList of model object
        .marshal().json(JsonLibrary.Jackson)
        .setHeader("Authorization", simple(apiKEY))
        .setHeader(Exchange.HTTP_METHOD, constant("POST"))
        .setHeader(Exchange.HTTP_URI, simple(API_URL))
        .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
        .to(API_URL)
        .to("mock:finish");
</code></pre>

<p>Error I am getting because of large POST body content length.</p>

<blockquote>
  <p>org.apache.camel.http.common.HttpOperationFailedException: HTTP
  operation failed invoking
  <a href="https://test.com/api/v2/receipts" rel="nofollow">https://test.com/api/v2/receipts</a> with statusCode:
  <strong>413</strong></p>
</blockquote>