Question

Unable to lookup contact from email via the API

  • 29 March 2022
  • 4 replies
  • 668 views

Badge

I am trying to integrate freshsales into our main application, at the moment I am just trying to connect contacts in freshsales to users on our system.  I can use the api to create users, and lookup them up by id, but when I try to look them up by email I get this error

{
"errors": {
"code": 403,
"message": [
"You are not authorized to perform this operation."
]
}
}

I am the admin of the account and as far as I can see have all the permissions that I can have.  What is going on here?


4 replies

Userlevel 4
Badge +8

Hello, 

Greetings from the Freshworks Comunity. 

The error code 403 indicates that the user whose credentials were used in making this request was not authorized to perform this API call. It could be that this API call requires admin level credentials where the API key used should be of the account admin. The format in which the API key should be inserted is “Token token=API key” 

Please find the sample lead creation API key for your reference,

curl -H "Authorization: Token token=sfg999666t673t7t82" -H "Content-Type: application/json" -d '{"lead":{"first_name":"Eric", "last_name":"Sampleton (sample)", "mobile_number":"1-926-652-9503", "company": {"name":"Widgetz.io (sample)"} }}' -X POST "https://yourdomain.freshsales.io/api/leads”

Do refer to this article for all the sample API calls - https://developer.freshsales.io/api/#leads with the respective format and let us know in case of any further queries.

Have a good day!

 

Badge

Hi,

 

I am the account admin and I managed to get other calls to work. 

I then realised that I was looking at the freshdesk API documentation instead of the freshsales API documentation when I was putting together the call to get a contact by email.

I don’t see any method for getting the contact by email in the freshsales API.  How would I do that?

Userlevel 4
Badge +8

Hello, 

To filter a contact based on the email address, the filtered search API should be used. Please refer to this article for the sample filtered search API - https://developer.freshsales.io/api/#search 

Below is the sample curl command where the filter attribute should be given as the email address, 

curl -H 'Authorization: Token token=sfg999666t673t7t82' -H 'Content-Type:application/json' -X POST https://domain.freshsales.io/api/filtered_search/contact -d '{ "filter_rule" : [{"attribute" : "contact_email.email", "operator":"is_in", "value":"jamessampleton@gmail.com"}] }

This command will result in the record with the specific email address mentioned. 

I hope this helps. Do let us know in case of further queries. 

Badge

Thank you.

 

I notice that I don’t get any custom fields returned when I use the filtered_search api, is there a way to include custom fields in the result?

Reply