# 'error': 'no handler found for uri \[/test\_network\_data/json/1\] and method \[PUT\]'

**URL:** <https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 20, 2023, 11:00pm UTC](https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563 "2023-11-20T23:00:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philip\_Doyle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_doyle/32/127809_2.png) [@Philip\_Doyle](https://discuss.elastic.co/u/Philip_Doyle)\
**Post date:** [November 20, 2023, 11:00pm UTC](https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563/1 "2023-11-20T23:00:30Z")

</div>

As stated in the title, when I try to use the index API in python to index a json document, I get this error every time. I am brand new to the ELK stack but have followed the quick start guides on their website and I have been stuck here for quite some time. If any one could provide some insight into what's going here that would much appreciated. Thank you!!

Below is the code that I am running to try and index my document.

```auto
from elasticsearch import Elasticsearch
import configparser
import json

data_file_name = "/home/phil/PcapFiles/test1.json"
config_file_name = "/home/phil/ElasticPython/configuration.ini"

# Load config file for elastic user for ElasticSearch
config = configparser.ConfigParser()
config.read(config_file_name)

# Create the client instance
client = Elasticsearch(
    cloud_id=config["ELASTIC"]["cloud_id"],
    http_auth=(config["ELASTIC"]["user"], config["ELASTIC"]["password"])
)

# Successful response!
print("\n\nConnection Status Server Response...")
print("--------------------------------------------------------------\n")
print(client.info())

# create new index (like a new table in a database)
#print("\n\nIndex Creation Server Response...")
#print("---------------------------------------------------------------\n")
#resp = client.indices.create("test_network_data")
#print(resp)

# refresh newly created index
client.indices.refresh(index="test_network_data")

# send json formated data to ElasticSearch server
print("\n\nData Transmission Server Response...")
print("---------------------------------------------------------------\n")
f = open(data_file_name)
f_content = f.read()
response = client.index(index="test_network_data", ignore=400, doc_type="json", id=1, document=json.loads(f_content))
print(response)

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [November 20, 2023, 11:13pm UTC](https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563/2 "2023-11-20T23:13:26Z")

</div>

Which version of the Elasticsearch library are you using, and which version is your Elasticsearch?

> [@Philip\_Doyle](#):
>
> `doc_type="json"`

This should not be used, Elasticsearch does not uses type since version 7.X.

Try to remove this and see if it works.

---

<div class="post-metadata">

**Author:** ![Philip\_Doyle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_doyle/32/127809_2.png) [@Philip\_Doyle](https://discuss.elastic.co/u/Philip_Doyle)\
**Post date:** [November 20, 2023, 11:39pm UTC](https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563/3 "2023-11-20T23:39:22Z")

</div>

Thanks @leandrojmp for such a quick reply!! I am using version 8.11 for the library and 8.11 for Elastic search (setup through their own cloud service). I removed the `doc_type="json"` as you mentioned and now I get the following error:

> ApiError(500, 'not\_x\_content\_exception', 'not\_x\_content\_exception: Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes')

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [November 21, 2023, 2:28am UTC](https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563/4 "2023-11-21T02:28:59Z")

</div>

If I'm not wrong this error happens when the content you are sending to Elasticsearch is not in the correct format.

What is the content of your file?

> [@Philip\_Doyle](#):
>
> ```auto
> f = open(data_file_name)
> f_content = f.read()
> 
> ```

Add a `print(f_content)` to your code and share it.

---

<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:** [December 19, 2023, 2:29am UTC](https://discuss.elastic.co/t/error-no-handler-found-for-uri-test-network-data-json-1-and-method-put/347563/5 "2023-12-19T02:29:38Z")

</div>

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