Fatal error: “The endpoint isn't allowed on places”

I receive this error message when trying to use the addObjects() function to push some data to a new account.

Here is my code:

<?php

require 'vendor/autoload.php';

// Create the Algolia Search Client and add the objects to the summitpost_pages index
$client = new \AlgoliaSearch\Client('myAppID', 'myAdminAPIKey');
$index = $client->initIndex('summipost_pages');
$actors = [
    ['name'=>'Tom Cruise', 'rating'=>1200],
    ['name'=>'Lucy Liu', 'rating'=>1299]
];

$index->addObjects($actors);

Results is: PHP Fatal error: Uncaught AlgoliaSearch\AlgoliaException: The endpoint isn’t allowed on places in vendor/algolia/algoliasearch-client-php/src/AlgoliaSearch/Client.php:1371

Interestingly, I see the same message in my account on the Infrastructure tab. See the attached image.

What am I doing wrong?

Hi @summitpost I think you created an account on Algolia via https://community.algolia.com/places/ at some point and then tried to reuse the same APPID/API key of this places application for a generic Algolia usage.

To solve this, you have to create a new application in your dashboard, a regular Algolia application, and then start over.

If that does not fix it or if there’s something else to discuss, reach to us at support@algolia.com with details on your application ID.

1 Like

Thank you for your response! I actually worked my way through figuring that one out thanks to an email from support.

I was able to get a new APPID/API key, create an index, and then do addObject() to insert data into it! Yay!

Now I’m getting another error message when I try to use addObjects(), and the error message means nothing to me:

PHP Fatal error: Uncaught AlgoliaSearch\AlgoliaException: body of batch should be an object and not an array

Can you help with this error as well, or should I start another thread?

Hi!

Our addObject method acepts a single object, while addObjects accepts an array of objects, as documented here. You can see examples here.

Cheers!

Thank you, Sarah. I was able to figure out my mistake with the structure of the objects array. I’m all set now!