# Problems while using \_bulk api via camel rest route

**URL:** <https://discuss.elastic.co/t/problems-while-using-bulk-api-via-camel-rest-route/336238>\
**Category:** Elasticsearch\
**Created:** [June 16, 2023, 2:36pm UTC](https://discuss.elastic.co/t/problems-while-using-bulk-api-via-camel-rest-route/336238 "2023-06-16T14:36:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markchennai](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@markchennai](https://discuss.elastic.co/u/markchennai)\
**Post date:** [June 16, 2023, 2:36pm UTC](https://discuss.elastic.co/t/problems-while-using-bulk-api-via-camel-rest-route/336238/1 "2023-06-16T14:36:57Z")

</div>

## Message History (source location and message history is disabled)

Source ID Processor Elapsed (ms)  
route1/route1 from[timer://first-timer] 7943647  
...  
route1/to1 rest:post:/\_bulk 0

## Stacktrace

org.apache.camel.http.base.HttpOperationFailedException: HTTP operation failed invoking [http://localhost:9200/\_bulk](http://localhost:9200/_bulk) with statusCode: 400  
at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:422) ~[camel-http-3.20.5.jar:3.20.5]  
at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:294) ~[camel-http-3.20.5.jar:3.20.5]  
at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:66) ~[camel-support-3.20.5.jar:3.20.5]  
at org.apache.camel.component.rest.RestProducer.process(RestProducer.java:83) ~[camel-rest-3.20.5.jar:3.20.5]  
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:172) ~[camel-core-processor-3.20.5.jar:3.20.5]  
at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) ~[camel-core-processor-3.20.5.jar:3.20.5]  
at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:181) ~[camel-base-engine-3.20.5.jar:3.20.5]  
at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) ~[camel-base-engine-3.20.5.jar:3.20.5]  
at org.apache.camel.processor.Pipeline.process(Pipeline.java:165) ~[camel-core-processor-3.20.5.jar:3.20.5]  
at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:392) ~[camel-base-engine-3.20.5.jar:3.20.5]  
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210) ~[camel-timer-3.20.5.jar:3.20.5]  
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76) ~[camel-timer-3.20.5.jar:3.20.5]  
at java.base/java.util.TimerThread.mainLoop(Timer.java:566) ~[na:na]  
at java.base/java.util.TimerThread.run(Timer.java:516) ~[na:na]

2023-06-16 09:28:06.502 WARN 32000 --- [r://first-timer] o.a.camel.component.timer.TimerConsumer : Error processing exchange. Exchange[458FCA3ACF100D6-0000000000000005]. Caused by: [org.apache.camel.http.base.HttpOperationFailedException - HTTP operation failed invoking [http://localhost:9200/\_bulk](http://localhost:9200/_bulk) with statusCode: 400]

org.apache.camel.http.base.HttpOperationFailedException: HTTP operation failed invoking [http://localhost:9200/\_bulk](http://localhost:9200/_bulk) with statusCode: 400

bulkRequest :  
String bulkRequest = "{"index": {"\_index": "" + index + "", "\_type": "" + type + ""}}\n" +  
"{"field1": "value1"}\n" +  
"{"index": {"\_index": "" + index + "", "\_type": "" + type + ""}}\n" +  
"{"field2": "value2"}\n";

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 17, 2023, 7:36am UTC](https://discuss.elastic.co/t/problems-while-using-bulk-api-via-camel-rest-route/336238/2 "2023-06-17T07:36:03Z")

</div>

Which version of Elasticsearch are you using? Document types have been deprecated so if you are indexing into a recent version you may want to remove the type [as shown in the docs](https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docs-bulk.html).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 15, 2023, 7:37am UTC](https://discuss.elastic.co/t/problems-while-using-bulk-api-via-camel-rest-route/336238/3 "2023-07-15T07:37:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
