# Incorrect HTTP method for uri

**URL:** <https://discuss.elastic.co/t/incorrect-http-method-for-uri/320931>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 9, 2022, 8:27pm UTC](https://discuss.elastic.co/t/incorrect-http-method-for-uri/320931 "2022-12-09T20:27:12Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 11, 2022, 4:07pm UTC](https://discuss.elastic.co/t/incorrect-http-method-for-uri/320931/6 "2022-12-11T16:07:53Z")

</div>

Take a look at this ...

> [@Connecting to Elasticsearch node in Elastic cloud through python promt](https://discuss.elastic.co/t/connecting-to-elasticsearch-node-in-elastic-cloud-through-python-promt/289028/4):
>
> I just did this from elasticsearch import Elasticsearch # you can use RFC-1738 to specify the url # ... or specify common parameters as kwargs es = Elasticsearch( cloud\_id="mycluster:sdfgsdfgdsfgdsfglvdsfgsdfgdsfgmNiM2JkNzRjNDY3JGIxZTUyOWEwNTBkNjRkODZhMzIxZTBhMjU3YjRlODhh", http\_auth=("elastic", "dsfgsdfgsdfgg"), ) output = es.info(), print(output, end=" ") and it worked fine... This also worked fine... es = Elasticsearch( cloud\_id="mycluster:sdfgsdfgdsfgdsfgsdfgsdfgsdfgsdfg…

OK I just tested this and all works as expected.

```auto
POST /_security/api_key
{
  "name": "my-discuss-api-key",
  "expiration": "1d",   
  "role_descriptors": { 
    "role-a": {
      "cluster": ["all"]
      
    }
  }
}
# Result
{
  "id": "sadfasdfGGJCaJCcrUTy",
  "name": "my-discuss-api-key",
  "expiration": 1670861752818,
  "api_key": "asfdasdf9YOve4r3g",
  "encoded": "cXlINEFZVUJHR0pDYUpDY3JVVHk6Q3JEeTNfbC1SdHVEMzlZT3ZlNHIzZw=="
}

```

Both Options Work

```auto
from elasticsearch import Elasticsearch

es = Elasticsearch(
	  "https://my-demo-cluster.es.us-west1.gcp.cloud.es.io:443",
    api_key=("sadfasdfGGJCaJCcrUTy", "asfdasdf9YOve4r3g"),
)

# es = Elasticsearch(
# cloud_id="my-demo-cluster:asdfsadfasdfkLmVzLmlvJDA1M2Y1MWYwMDViOTRjNDA4NGMzNmNiM2JkNzRjNDY3JGIxZTUyOWEwNTBkNjRkODZhMzIxZTBhMjU3YjRlODhh",
# api_key=("sadfasdfGGJCaJCcrUTy", "asfdasdf9YOve4r3g"),
# )

output = es.info(),

print(output, end=" ")

```

```auto
(ObjectApiResponse({'name': 'instance-0000000095', 'cluster_name': 'sadfsadf4c4084c36cb3bd74c467', 'cluster_uuid': 'sadfsadfa-k2eXlBQ', 'version': {'number': '8.5.3', 'build_flavor': 'default', 'build_type': 'docker', 'build_hash': '4ed5ee9afac63de92ec98f404ccbed7d3ba9584e', 'build_date': '2022-12-05T18:22:22.226119656Z', 'build_snapshot': False, 'lucene_version': '9.4.2', 'minimum_wire_compatibility_version': '7.17.0', 'minimum_index_compatibility_version': '7.0.0'}, 'tagline': 'You Know, for Search'}),)

```

**Exactly** what error are you getting. when you state it is not working you have to show the exact code and the error messages otherwise we are just guessing.

---

_[View the full topic](https://discuss.elastic.co/t/incorrect-http-method-for-uri/320931)._
