#Can't Add additionalEmails via API

1 messages · Page 1 of 1 (latest)

lilac shadow
#

As far as I can tell, I should be able to send an array, e.g. "additionalEmails": ["[email protected]"]. But when I do, I get back this error:

400 - "{"statusCode":400,"error":"SyntaxError","messages":["Unexpected token 'g', \"[email protected]\" is not valid JSON"]}"

Honestly don't know what this means or what to do about it.

stark epoch
#

Hello @lilac shadow thank you for the report, checking that today

stark epoch
#

@lilac shadow I might miss something, it looks to work properly on our side. Can you share your request body? Here a working example to create one person:

{
  "name": {
    "firstName": "Raphaelle",
    "lastName": "Sporer"
  },
  "emails": {
    "primaryEmail": "[email protected]",
    "additionalEmails": [
      "[email protected]",
      "[email protected]"
    ]
  }
}
lilac shadow
#

I'll recheck later today and get back to you.

lilac shadow
#

I tried passing this again:
"emails": { "primaryEmail": "[email protected]", "additionalEmails": [ "[email protected]" ] }

And I am now getting an error basically saying that I am not passing an array but a string:

400 - "{"statusCode":400,"error":"BadRequestException","messages":["malformed array literal: \"\""]}"

stark epoch
#
{"emails": { "primaryEmail": "[email protected]", "additionalEmails": [ "[email protected]" ] }}

Works on my side.
Are you sure you format your body properly? Error suggests that some escape '\' characters are inserted in your body

lilac shadow
#

@inland kettle I am. And I tried removing the emails too. Then I get new errors, e.g. "unexpected end of JSON" and such. Not sure what the underlying cause of all this is. Using n8n for my API calls.

#

I get the impression it's not really the JSON, but rather how it is interpreted server-side

stark epoch
#

let me try with n8n

#

works well with n8n, there is something we miss

inland kettle
lilac shadow
#

1.0.0

inland kettle
#

Mmhmm indeed should be good

#

Are you updating a custom object field or a standard object field ?
Also is it the only update sent to through the payload no others fields ?

lilac shadow
#

Also custom object fields. Here's what I'm sending:
{
"body": {
"academicTitle": "",
"salutation": "Herr",
"formOfAddress": "Du",
"nickname": "Andi",
"language": "DE",
"name": {
"firstName": "firstName",
"lastName": "lastName"
},
"emails": {
"primaryEmail": "[email protected]",
"additionalEmails": [
"[email protected]",
"[email protected]"
]
},
"linkedinLink": {
"primaryLinkUrl": "https://linkedin.com/in/profile/someone"
},
"jobTitle": "Geschäftsführer",
"phones": "",
"companyId": "000711d4-6e74-4fc2-8d43-27c7302f0b1b"
},
"headers": {
"Authorization": "hidden",
"accept": "application/json,text/html,application/xhtml+xml,application/xml,text/;q=0.9, image/;q=0.8, /;q=0.7"
},
"method": "POST",
"uri": "https://crm.mydomain.com/rest/people",
"gzip": true,
"rejectUnauthorized": true,
"followRedirect": true,
"resolveWithFullResponse": true,
"followAllRedirects": true,
"timeout": 300000,
"encoding": null,
"json": false,
"useStream": true
}

inland kettle
#

The error might not come from the email update validation

lilac shadow
#

I'm actually using the fields, not raw JSON at the moment

#

I agree. It's something else.

inland kettle
#

Mhmm error feedback is not ideal here, this need to be improved, noting

stark epoch
#

let me try with fields

inland kettle
#

My bet is phones

stark epoch
#

with fields, using the PUT endpoint to update a record, it does not seems to work properly with n8n
But no error though, just wrong data after update

lilac shadow
#

Even this doesn't work:
{
"body": {
"academicTitle": "",
"salutation": "Herr",
"formOfAddress": "Du",
"nickname": "Andi",
"language": "DE",
"name": {
"firstName": "firstName",
"lastName": "lastName"
},
"linkedinLink": {
"primaryLinkUrl": "https://linkedin.com/in/profile/someone"
},
"jobTitle": "Geschäftsführer",
"companyId": "000711d4-6e74-4fc2-8d43-27c7302f0b1b"
},
"headers": {
"Authorization": "hidden",
"accept": "application/json,text/html,application/xhtml+xml,application/xml,text/;q=0.9, image/;q=0.8, /;q=0.7"
},
"method": "POST",
"uri": "https://crm.inside360.studio/rest/people",
"gzip": true,
"rejectUnauthorized": true,
"followRedirect": true,
"resolveWithFullResponse": true,
"followAllRedirects": true,
"timeout": 300000,
"encoding": null,
"json": false,
"useStream": true
}

lilac shadow
lilac shadow
inland kettle
#

Do you have an ARRAY field metadata type in this object metadata definition ?

lilac shadow
#

Two, actually: The additionalEmails and additionalPhones. But removing them did not eliminate the error. Don't see any other array and am not forming one on purpose ...

inland kettle
#

Sorry those two are PHONE and EMAIL field metadata type I was thinking about an atomic field metadata array not a composite one

lilac shadow
#

Or could it maybe be expecting an array due to my custom fields?

inland kettle
#

Mhmm

#

Could you please try to use 1.0.1

lilac shadow
#

Will update now

inland kettle
#

Erf this won't have an impact anw as the data already exists in local

#

We're currently about to ship 1.0.2 that contains a retro-compatible command

#

Unfortunately I won't be able to give your issue a deep sight until at least 2 hours
When the 1.0.2 is shipped I'll let you know so we could put the array issue on the side but honestly would be suprising to be this

stark epoch
#

Yes can you share your data model from settings (offuscate if needed)

#

?

lilac shadow
#

If I have a custom field such as this:
salutation
Type:string
enum
HERR
FRAU
MR
MS

What is the expected format for the API? I am using {"salutation": "Herr"}

stark epoch
lilac shadow
#

BTW: Let me say a big THANK YOU for your effort in trying to help me @stark epoch @inland kettle 🫶 !

inland kettle
#

Of course you're welcome @lilac shadow !
Will try to reproduce on my side once 1.0.2 is shipped

lilac shadow
#

So I just deleted one field after another until the request went through. What I learned: It's the custom fields that are the problem: academicTitle, salutation and formOfAddress specifically. Apparently, filling them via {"fieldName": "value"} is not cutting it and causing issues. Not sure of the cause though. Should I be using a different syntax?

#

Further testing: Apparently the API expects me to transmit the values for these custom fields in all caps (e.g. "HERR" or "SIE". Even though I set "Herr" and "Sie" as values in the custom fields themselves. BTW: They are also displayed as "Herr" and "Sie" on the frontend after creation.

#

Am I the first one to try this or was everyone else that much smarter 🤣 ?

stark epoch
#

jeez, they are select and multiSelect fields, did not catch that, indeed value should be set specifically for those

#

No there is no doc for those, we really need one 😅

#

lets me provide you an example

#

{"accademicTitle": [], ...} (instead of {"accademicTitle": "", ...}) should fix the issue

#

accademicTitle is a multiSelect, so expecting an array value, not a string (this is what the error message says, very badly 😑)

#

Sorry for the disturbance — we shouldn't have to struggle this much over such an issue.

stark epoch
#

Complete fix:

{
        "academicTitle": [],
        "salutation": "HERR",
        "formOfAddress": "DU",
        ...
}
lilac shadow
#

Thanks for the update. I'm over the hump and can now continue the migration :-).

stark epoch
#

great, very pleased to ear that

#

Thank you for your patience