Menu
SuiteCRM dedicated support by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: API v8: getting account email addresses

API v8: getting account email addresses 4 months 3 days ago #69115

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • Senior Member
  • Posts: 49
  • Thank you received: 6
  • Karma: 5
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 4 months 3 days ago #69118

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8202
  • Thank you received: 1263
  • Karma: 296
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...

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
Last Edit: 4 months 2 days 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 4 months 3 days ago #69121

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • Senior Member
  • Posts: 49
  • Thank you received: 6
  • Karma: 5
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 4 months 2 days ago #69186

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8202
  • Thank you received: 1263
  • Karma: 296
Have you tried this way of listing available modules?

docs.suitecrm.com/developer/api/version-...st_available_modules

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

API v8: getting account email addresses 4 months 1 day ago #69232

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • Senior Member
  • Posts: 49
  • Thank you received: 6
  • Karma: 5
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: 4 months 1 day ago by fanton.ff.
The administrator has disabled public write access.

API v8: getting account email addresses 4 months 1 day ago #69258

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8202
  • Thank you received: 1263
  • Karma: 296
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... :-(

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

API v8: getting account email addresses 4 months 1 day ago #69285

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • Senior Member
  • Posts: 49
  • Thank you received: 6
  • Karma: 5
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 months 1 day ago #69290

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8202
  • Thank you received: 1263
  • Karma: 296
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.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: fanton.ff

API v8: getting account email addresses 3 months 21 hours ago #70422

  • rjpint
  • rjpint's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Hi im trying to do a similar thing my call is /api/v8/modules/EmailAddresses/814979d4-06a5-4b0c-9361-5b717388bd51 but i get the following error in response.
"errors": [
        {
            "id": "1",
            "links": {
                "about": null
            },
            "status": 500,
            "code": 8025,
            "title": "JSON API Error",
            "detail": "Api Version: 8",
            "source": {
                "pointer": null,
                "parameter": null
            },
            "meta": {
                "about": "Exception",
                "class": "SuiteCRM\\API\\v8\\Exception\\ApiException",
                "code": 8025,
                "langMessage": null
            }
        },

Does your call to EmailAddresses still work?
The administrator has disabled public write access.

API v8: getting account email addresses 2 months 3 weeks ago #70599

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • Senior Member
  • Posts: 49
  • Thank you received: 6
  • Karma: 5
Yes it's still working... Have you tried checking suitecrm.log? Maybe increasing the log level from the administration panel?
The administrator has disabled public write access.
The following user(s) said Thank You: rjpint

API v8: getting account email addresses 2 months 3 weeks ago #70640

  • rjpint
  • rjpint's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Thank you fanton.ff raising the log level has highlighted what I believe to be the issue retrieving the email addresses as it's throwing a FATAL on converting the datetime field using SugarBean. here is the full error;

[FATAL] [SuiteCRM] [API] [Unable to convert datetime field using SugarBean] "confirm_opt_in_date"

Do you have any thoughts on how I fix this?
The administrator has disabled public write access.

API v8: getting account email addresses 2 months 3 weeks ago #70641

  • rjpint
  • rjpint's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
If I go to the database email_addresses table and fill out all the date fields it retrieves the email address no problem however as soon as one is null I have the error.

It’s good that we have found what is causing the issue but I think this is one will need resolving in the API code.
The administrator has disabled public write access.

API v8: getting account email addresses 2 months 3 weeks ago #70643

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8202
  • Thank you received: 1263
  • Karma: 296
I suggest you open an issue with that precise information in Github, it will be useful to fix the issue.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

API v8: getting account email addresses 2 months 3 weeks ago #70649

  • fanton.ff
  • fanton.ff's Avatar
  • Offline
  • Senior Member
  • Posts: 49
  • Thank you received: 6
  • Karma: 5
I had the same problem and opened an issue a while ago: github.com/salesagility/SuiteCRM/issues/6148
Last Edit: 2 months 3 weeks ago by fanton.ff.
The administrator has disabled public write access.
Time to create page: 0.095 seconds
Powered by Kunena Forum