Menu

Welcome, Guest
Username: Password: Remember me

TOPIC: API v8: getting account email addresses

API v8: getting account email addresses 1 week 16 hours ago #69115

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Thank you received: 1
  • Karma: 0
Hi everyone!

I'm trying to get the email addresses associated with a specific Account, using the new JSON v8 API.
I can get my access token and use it to fetch the Account, now I'd like to get its email addresses too (I know that this particular account has two email addresses).

I've tried calling the
api/v8/modules/Accounts/{ACCOUNTID}/relationships/email_addresses
endpoint, here's the data I'm receiving back:
[{'id': '1ee15ac7-18d3-96d7-035d-5b3f3c3dba94',
  'links': {'href': 'http://devcrm/api/v8/modules/Accounts/1ee15ac7-18d3-96d7-035d-5b3f3c3dba94'},
  'meta': {'middle_table': {'data': {'attributes': {'bean_id': 'a5ec312f-b1dc-d401-d3be-5b23b3058722',
                                                        'bean_module': 'Accounts',
                                                        'date_created': '2018-07-06 09:53:48',
                                                        'date_modified': '2018-07-06 09:53:48',
                                                        'deleted': '0',
                                                        'email_address_id': '1ee15ac7-18d3-96d7-035d-5b3f3c3dba94',
                                                        'id': '1ee15ac7-18d3-96d7-035d-5b3f3c3dba94',
                                                        'primary_address': '0',
                                                        'reply_to_address': '0'},
                                        'id': '',
                                        'type': 'Link'}}},
  'type': 'EmailAddresses'},
 {'id': '8f42881c-d788-9a69-15b3-5b3f3be9705f',
  'links': {'href': 'http://devcrm/api/v8/modules/Accounts/8f42881c-d788-9a69-15b3-5b3f3be9705f'},
  'meta': {'middle_table': {'data': {'attributes': {'bean_id': 'a5ec312f-b1dc-d401-d3be-5b23b3058722',
                                                        'bean_module': 'Accounts',
                                                        'date_created': '2018-07-06 09:49:13',
                                                        'date_modified': '2018-07-06 09:49:13',
                                                        'deleted': '0',
                                                        'email_address_id': '8f42881c-d788-9a69-15b3-5b3f3be9705f',
                                                        'id': '8f42881c-d788-9a69-15b3-5b3f3be9705f',
                                                        'primary_address': '0',
                                                        'reply_to_address': '0'},
                                        'id': '',
                                        'type': 'Link'}}},
  'type': 'EmailAddresses'}]

As you can see, there are two "branches", one for each email address, but the REAL addresses (x@y.com) are nowhere to be seen, only the "email_address_id"s. Is this normal? Should I use the "email_address_id"s to make another call to the server? I'm not sure how I should do that though.

Many thanks for your time!
The administrator has disabled public write access.

API v8: getting account email addresses 1 week 16 hours ago #69118

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
Email addresses is a module, and the email fields are related fields. So I can understand what you're seeing, and yes, you could do a second request to get the actual address from the email_addresses table.

The table you're seeing in that API return seems to be email_address_bean_rel

See this page (not official yet, but you can preview it), scroll to the bottom to see a diagram.

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

But all of this comes from my knowledge of the database; I don't know much about the API...
Last Edit: 6 days 16 hours ago by pgr. Reason: fix link
The administrator has disabled public write access.
The following user(s) said Thank You: fanton.ff

API v8: getting account email addresses 1 week 16 hours ago #69121

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Thank you received: 1
  • Karma: 0
Hi, thanks for your answer!
I see that the database has a "email_addresses" table that maps the "email_address_id" (mentioned by the API response) to the real email addresses, but I can't figure out how to fetch it using the API :( I've tried calling
api/v8/modules/EmailAddresses/1ee15ac7-18d3-96d7-035d-5b3f3c3dba94
but I received a ModuleNotFoundException
The administrator has disabled public write access.

API v8: getting account email addresses 6 days 15 hours ago #69186

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
Have you tried this way of listing available modules?

docs.suitecrm.com/developer/api/version-...st_available_modules
The administrator has disabled public write access.

API v8: getting account email addresses 5 days 16 hours ago #69232

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Thank you received: 1
  • Karma: 0
Yes I did try that, here's the answer:
AM_ProjectTemplates
AOBH_BusinessHours
AOK_KnowledgeBase
AOK_Knowledge_Base_Categories
AOR_Reports
AOR_Scheduled_Reports
AOS_Contracts
AOS_Invoices
AOS_PDF_Templates
AOS_Product_Categories
AOS_Products
AOS_Quotes
AOW_WorkFlow
Accounts
Bugs
Calendar
Calls
Campaigns
Cases
Contacts
Documents
EmailTemplates
Emails
FP_Event_Locations
FP_events
Home
Leads
Meetings
Notes
Opportunities
Project
ProspectLists
Prospects
ResourceCalendar
SecurityGroups
Spots
Surveys
Tasks
jjwg_Address_Cache
jjwg_Areas
jjwg_Maps
jjwg_Markers

As you can see, no "EmailAddresses"
Last Edit: 5 days 16 hours ago by fanton.ff.
The administrator has disabled public write access.

API v8: getting account email addresses 5 days 12 hours ago #69258

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
I double-checked and I think that list is buggy it's getting values from a different list called "moduleL1ist", instead of "beanList" (see include/modules.php).

So EmailAddresses should really be working. The API just calls the Beans, and that's a valid Bean name...

Any way you can try variations like

Email_Addresses
EmailAddress
etc

I am a bit confused by what is going on here... :-(
The administrator has disabled public write access.

API v8: getting account email addresses 4 days 21 hours ago #69285

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Thank you received: 1
  • Karma: 0
Well I'm MORE confused than you, since today the call to the EmailAddresses module IS working *blush*
Maybe I was doing something wrong... Many thanks for your assistance :)
BTW, what's the recommended way to propose a fix for the "list available modules" issue? GitHub?
The administrator has disabled public write access.

API v8: getting account email addresses 4 days 19 hours ago #69290

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
Cool, I'm glad you got it working!

Yes, you can propose fixes on Github. However, there's a big PR with a refactored v8 API waiting to be merged, so I would wait for that, or have a look at that PR:

github.com/salesagility/SuiteCRM/pull/5806

and comment there if you think it still needs that fix.
The administrator has disabled public write access.
The following user(s) said Thank You: fanton.ff
Time to create page: 0.108 seconds
Powered by Kunena Forum