queryContacts() forbidden response

I am getting the following error when making the queryContacts() request in live:

Code:

const queryResults = await contacts . queryContacts ()
. eq ( “info.emails.email” , emailToFind )
. find ();

Response:

“[“message: ‘’\ndetails:\n applicationError:\n description: Forbidden\n code: FORBIDDEN\n data: {}”]”

This worked fine when running in sandbox but as soon as I pushed the code to live, the error persists. Is this a permissions issue for querying the CRM contacts list?

1 Like

I too am experiencing the same behavior. Works on preview but not in live. 6/11/2021

I spoke with Wix support and they have opened a ticket with the Velo team. Once I hear back form them, I’ll post their recommendation.

From Velo team:

To resolve the permissions issue you are experiencing, use wixDataOptions to override admin permissions as shown below:

let options = {
“suppressAuth” : true ,
“suppressHooks” : true
};

const queryResults = await contacts . queryContacts ()
. eq ( “info.emails.email” , emailToFind )
. find ( options );

Useful!

Thanks, I am able to get beyond the error now!

I see the wix-crm-backend - Contacts.queryContact.find option only has one: suppressAuth

but the wix-data - query.find option has two:
suppressAuth
suppressHooks

I am using the both options with the queryContacts.find and it is now returning results. Question - is this call ignoring the suppressHooks option?

In this case i can’t give an answer due to lack of knowledge, sorry.

Great tip! This works like a charm and was a tough one to find! Truly appreciate your response and contribution!

@mike91901 had me pretty stumped too. Glad it’s helping folks out

@petedoppler Glad to hear that you got the solution here!