Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Not enough rights to add an object" error while implementing Algolia

Tags:

algolia

I'm trying to index contacts in Algolia.
Here is my code:

StreamReader re = File.OpenText("contacts.json");
JsonTextReader reader = new JsonTextReader(re);`
JArray batch = JArray.Load(reader);
// Add objects 
Index index = client.InitIndex("contacts");

index.AddObjects(batch);

I'm getting an error on the last line:

Not enough rights to add an object
like image 630
Ketan Vaghasiya Avatar asked Apr 28 '16 13:04

Ketan Vaghasiya


3 Answers

It seems like you're using an API key that doesn't have the "Add records" ACL in Algolia.

You probably used your search API key, when you want to use an API key with write permission to your index, e.g. your Admin API key.

like image 156
Jerska Avatar answered Nov 16 '22 20:11

Jerska


I was getting this error because I was using the Search API in Firebase when using the Algolia extension. It's weird because there it says "Do not use the Admin API key" but guess what, the Admin key is the one that works...

like image 29
Kerox Avatar answered Nov 16 '22 20:11

Kerox


You can create a new API Key and give it specific permissions, to search and addObjects in the ACL input field. You can create a new API Key in your Dashboard when selecting 'ALL API Keys'.

Algolia recommends to use your admin key only for backend search and create a new key for frontend search.

Here is some supporting documentation from Algolia https://www.algolia.com/doc/guides/security/api-keys/#rights-and-restrictions

like image 4
C-Dev Avatar answered Nov 16 '22 18:11

C-Dev