Sendgrid - Search Contacts API call json body syntax

HI There

I am trying to setup an API call in order to download a contact ID based on an email address.

https://docs.sendgrid.com/api-reference/contacts/search-contacts

I am struggling with the json syntax I need to add in the API call’s body.
The examples given by Sendgrid are following:

Basically I need to query just 1 email address.

Thanks for help.

What did you tried? Can you share API connector screenshot? Which error do you get?

Hello

I am trying to get the contact’s ID based on the email address.

Authorization and Headers are correct, since I use them for other API calls which work fine.

The Search contacts call is the on giving me trouble.

And this is the error message. Really basic invalid format error message.

Thanks!

According to the first endpoint link, the payload should be more like
{"query": "email LIKE '<email>'"}
(don’t forget single quotes, that you don’t have in your request).
Also, add Content-type: application/json header

1 Like

Thanks!! Works now!

Really appreciated!

Hi

Initializing worked but then I do not get the usual list of data to choose from. That seems odd…

Initialising seems OK.

Thanks!

You need to select results. The API return a list. You may select results:first item

1 Like

Ah. Yes that was it.
What when the output is a list? Because with :first item it gives wrong results.

What do you mean by wrong results?
First item will give you the first contact.
In this contact, you will have a list of “list” that the user is member. This is a list of text according to your screenshot.
Maybe your search constraint should be email = (IS) instead of LIKE

running the workflow (bulk from backend) for list id’s adds always the same 3 list id’s to all contacts.

Screenshot 2023-07-12 at 16.25.34

IS does not seem to be an option. LIKE seems the way to go for Sendgrid.

not is but =
And this is not impossible that different contact be on the same lists

I checked them manually. They are all wrong. It’s always the same 3 IDs that are being added.

Do the search return the correct contact?

I tried with =

A new set of the same 3 ID’s gets added to all contacts.

Before

After running the wf. I checked on Sendgrid. Those are not the correct lists.

One is on two lists.
Another on none.
The third on one list.

How do you set this field? Do you send the data to a schedule on a list WF? What do you do with the list of contact returned?

Initialiyzing with the contact that is on 2 lists gives at least one correct one.

Screenshot 2023-07-12 at 18.20.35

Is the contact found is the correct one?
Is there more than 1 contact returned for this email?

the contact id is correct and just 1 email is found

I don’t know Sendgrid enough to help you more. You can call the endpoint Get a Contact by ID | Twilio and check if you get the same result