PHP Client 8.5 Not Response Data

When try request do elastic using php client response it's returning always null, I've try using "search", "get" methodos and not working, when a try use postman request it's working, sample code below

Request Status Code: 200
Body: Null

$client = ClientBuilder::create()
                ->setBasicAuthentication(
                    config('elasticsearch.user'),
                    config('elasticsearch.password')
                )
                ->setHosts($app['config']->get('elasticsearch.hosts'))
                ->setCABundle(config('elasticsearch.certificate'))
                ->build();

$client->get([
            'index' => 'company',
            'id' => '31244951000130'
        ])->getBody->getContents();

I found the problem, I missed set the return as "asArray()"

$response->asArray()
1 Like

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