Skip to content

Incorrect HTTP method for uri [/] and method [PUT] when trying to create an index #1014

@GinoPane

Description

@GinoPane

Summary of problem or feature request

I got this error when tried to create an index:

{"error":"Incorrect HTTP method for uri [/] and method [PUT], allowed: [HEAD, DELETE, GET]","status":405}

I traced it down and found out that the reason is elasticsearch host. Originally, it had a trailing slash in my settings. And it worked fine for getAlias() for example. But failed for indices()->create().

The host URI needs to be sanitized probably.

Code snippet of problem

$params = [
    'index' => $newIndexName,
];

$this->esClient->indices()->create($params));

System details

  • Operating System Ubuntu 18.04
  • PHP Version 7.4.4
  • ES-PHP client version 7.6.1
  • Elasticsearch version 7.4

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions