ChrisB
ChrisB

Reputation: 2048

Contentful Query Content Types in PHP

I am very new to Contentful and trying to get all items of one particular content type "companies" from my Contentful database, but I get the error:

`400 Bad Request` response: { "sys": { "type": "Error", "id":
"InvalidQuery" }, "message": "The query you sent was invalid. Probably
a (truncated...) in

My code is:

$client = new Client($accessToken, $spaceID);
$query = new \Contentful\Delivery\Query();
$query->setContentType('hosting_companies');
$entries = $client->getEntries($query);

Does anybody know what I might be missing?

Thanks a lot!

Upvotes: 0

Views: 588

Answers (2)

ChrisB
ChrisB

Reputation: 2048

I have found out the source of the problem: In Contentful we called the content type hosting_companies. Contentful turned that into hostingCompanies (CamelCase) and I didn't realise that. As soon as I changed the query, it worked.

Upvotes: 2

stefan judis
stefan judis

Reputation: 3879

I'm not 100% fluent in the php sdk but you query for the content type id 'hosting' and in the description you say 'companies'?

Looking at this example in the Contentful documentation the overall structure looks okay.

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/content-type/query-entries/console/php

Upvotes: 1

Related Questions