Empty email address values via API

Hi,

I followed the API tutorial provided under https://docs.suitecrm.com/developer/api/version-8/.

I used https://domain-to-crm/api/v8/modules/Contacts as API URL to get all contacts. In general it worked. However, the “email” element is empty for every contact which gets returned. I am using API version 8 (I believe it is the latest version).

Any idea on why this happens and how to fix it is highly appreciated. :slight_smile:

Thanks,

Peter

I don’t really know about the API, but let me just venture a few guesses :slight_smile:

The way emails are stored in the database is a bit peculiar, it’s a related field. Have you tried looking for a way to traverse that relationship and get to a list of emails (instead of just trying to get a single email field)?

Also, I’ve seen places where that field is designated by “email1”: for example in the Contact bean.

Hey pgr, I believe you are right. I can add several email addresses for one contact so there has to be a relation between contacts and emails.

However, I don’t know how to access them. For testing I tried to extract all email addresses through …/api/v8/modules/Emails - I get no results although there are email addresses in the database.

I think the correct way would be extracting contacts and email addresses at one time via the API. But I don’t know how.

Any further ideas?

Peter

Update: As far as I understand the documentation, the correct way is fetching all contacts, then fetching the relationships and loop them again.

I am really thinking about creating a custom email field. I have never had a case where I need multiple email addresses per contact person (in any CRM system I have worked with).

Have you tried getting a field called email1 directly from the contact? (It works in the Bean, I never tried via the API).

I am currently working on this so I have to bring it up again.

email1 and email2 are also empty. But when I use the contact details (API via contact ID) then email1 is filled with the correct value. I think I will log an error at GitHub - I really believe this is abnormal behavior of the web service.

I am not so sure it’s a bug.

See this thread

https://suitecrm.com/suitecrm/forum/developer-help/19762-api-v8-getting-account-email-addresses

Email addresses is a module, and the email fields are related fields. So I can understand that the results aren’t coming directly with the initial query, the exception is if you look up a single contact it will do some behind-the-scenes work for you and give you email1 field directly.

You might need to get the relationship data, and do additional requests to get the actual address from the email_addresses table.

I see your point but I am not sure. What makes me think that this is a bug is the fact that the fields email, email1 and email2 are supplied via /api/v8/modules/Contacts but are empty. Why would the API provide empty fields in the contact list - fields that are not empty in contact details? Does not make sense to me.

The v8 API is new, and you might be the first person trying this :slight_smile:

Remember that the fields are in the Bean, and the API just gives out everything it finds. But fields present in the Bean might have different uses in different parts of the application. Sometimes they might have data, sometimes not.

And how could I find out if the behavior ist correct or not? What would you suggest? :slight_smile:

My advice is to forget about email1 and email2 fields, and try to use the API to navigate the actual structure of the database.

Understand the relationship table, email_addr_bean_rel:

https://schema–suitedocs.netlify.com/schema/tables/email_addr_bean_rel.html

It connects to all the module kinds that have emails, and connects to the email_addresses table where the actual email addresses are.