Update email address for related primary email for account is not possible via API #4966

Open
opened 2026-02-20 16:27:04 -05:00 by deekerman · 1 comment
Owner

Originally created by @vio-team on GitHub (Mar 1, 2023).

Issue

I tried to update an email address related to the account as primary address via API.
I found 2 ways, that looked like they could possibly solve my problem:

  1. PATCH request to account with relationships.
  2. POST request to add relationship.

Expected Behavior

  1. I would expect the PATCH request to have relationships as available option.
  2. I would expect the POST request to have attributes as available option.

Actual Behavior

Error for the first request:

The option "relationships“ does not exist. Defined options are: "attributes", "id", "type".

Error for the second request:

The option "attributes“ does not exist. Defined options are: "id", "type".

Possible Fix

Allow relationships as an option for a PATCH request to an account or allow attributes as an option for a POST request to a relationship.

Steps to Reproduce

Version 1 with PATCH request:

  1. Have an account with a primary email address.
  2. PATCH {{suitecrm.url}}/Api/V8/module
    body:
{
  "data": {
    "type": "Accounts",
    "id": {{id_account}},
    "attributes": {
      "name": "test"
    },
   "relationships": {
      "email_adresses": {
        "data": [{
          "id": {{id_email_new}},
          "type": "EmailAddress"
        }]
      }
    }
  }
}

Version 2 with POST request:

  1. Have an account with a primary email address.
  2. GET {{suitecrm.url}}/Api/V8/module/EmailAddress?filter%5Bemail_address%5D%5Beq%5D={{email_address_old}}
    if GET request was successfull, use id as {{id_email_new}} and continue with 4.
  3. POST {{suitecrm.url}}/Api/V8/module
    body:
{
  "data": {
    "type": "EmailAddress",
    "id": {{id_account}},
    "attributes": {
      "email_address": {{email_address_new}},
      "email_address_caps": {{email_address_new_caps}}
    }
  }
}

use id from response as {{id_email_new}}
4. GET {{suitecrm.url}}/Api/V8/module/Account/{{id_account}}/relationships/email_addresses
use id from response as {{id_email_old}}
5. DELETE {{suitecrm.url}}/Api/V8/module/Account/{{id_account}}/relationships/email_addresses/{{id_email_old}}
6. POST {{suitecrm.url}}/Api/V8/module/Account/{{id_account}}/relationships
body:

{
  "data": {
    "type": "EmailAddress",
    "id": {{id_email_new}},
    "attributes": {
      "primary_address": 1
    }
  }
}

Context

Our customers have the possibility to change their email addresses for their invoices. The concrete value that should change is email_addr_bean_rel.primary_address from 0 to 1.

Your Environment

  • SuiteCRM Version used: 8.1.2
  • Operating System and version (e.g Ubuntu 16.04): Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-58-generic x86_64)
Originally created by @vio-team on GitHub (Mar 1, 2023). #### Issue I tried to update an email address related to the account as primary address via API. I found 2 ways, that looked like they could possibly solve my problem: 1. PATCH request to account with `relationships`. 2. POST request to add relationship. #### Expected Behavior 1. I would expect the PATCH request to have `relationships` as available option. 2. I would expect the POST request to have `attributes` as available option. #### Actual Behavior Error for the first request: ``` The option "relationships“ does not exist. Defined options are: "attributes", "id", "type". ``` Error for the second request: ``` The option "attributes“ does not exist. Defined options are: "id", "type". ``` #### Possible Fix Allow `relationships` as an option for a PATCH request to an account or allow `attributes` as an option for a POST request to a relationship. #### Steps to Reproduce Version 1 with PATCH request: 1. Have an account with a primary email address. 2. PATCH {{suitecrm.url}}/Api/V8/module body: ``` { "data": { "type": "Accounts", "id": {{id_account}}, "attributes": { "name": "test" }, "relationships": { "email_adresses": { "data": [{ "id": {{id_email_new}}, "type": "EmailAddress" }] } } } } ``` Version 2 with POST request: 1. Have an account with a primary email address. 2. GET {{suitecrm.url}}/Api/V8/module/EmailAddress?filter%5Bemail_address%5D%5Beq%5D={{email_address_old}} if GET request was successfull, use id as {{id_email_new}} and continue with 4. 3. POST {{suitecrm.url}}/Api/V8/module body: ``` { "data": { "type": "EmailAddress", "id": {{id_account}}, "attributes": { "email_address": {{email_address_new}}, "email_address_caps": {{email_address_new_caps}} } } } ``` use id from response as {{id_email_new}} 4. GET {{suitecrm.url}}/Api/V8/module/Account/{{id_account}}/relationships/email_addresses use id from response as {{id_email_old}} 5. DELETE {{suitecrm.url}}/Api/V8/module/Account/{{id_account}}/relationships/email_addresses/{{id_email_old}} 6. POST {{suitecrm.url}}/Api/V8/module/Account/{{id_account}}/relationships body: ``` { "data": { "type": "EmailAddress", "id": {{id_email_new}}, "attributes": { "primary_address": 1 } } } ``` #### Context Our customers have the possibility to change their email addresses for their invoices. The concrete value that should change is `email_addr_bean_rel.primary_address` from `0` to `1`. #### Your Environment * SuiteCRM Version used: 8.1.2 * Operating System and version (e.g Ubuntu 16.04): Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-58-generic x86_64)
Author
Owner

@johnM2401 commented on GitHub (Mar 16, 2023):

Hey!
Thank you for getting in touch and raising this.

For future reference, this seems like it is similar to: https://github.com/salesagility/SuiteCRM/issues/8293

@johnM2401 commented on GitHub (Mar 16, 2023): Hey! Thank you for getting in touch and raising this. For future reference, this seems like it is similar to: https://github.com/salesagility/SuiteCRM/issues/8293
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4966
No description provided.