#Can't Add additionalEmails via API
1 messages · Page 1 of 1 (latest)
Hello @lilac shadow thank you for the report, checking that today
@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]"
]
}
}
I'll recheck later today and get back to you.
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: \"\""]}"
{"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
Are you self hosting ?
@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
What Twenty version are you hosting please ?
1.0.0
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 ?
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
}
The error might not come from the email update validation
I'm actually using the fields, not raw JSON at the moment
I agree. It's something else.
Mhmm error feedback is not ideal here, this need to be improved, noting
let me try with fields
My bet is phones
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
I tried exluding that and am getting errors then too
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
}
I'm actually trying to migrate all my data via the API. SOmeone messed up the field data in Pipedrive and using Excel would take me even longer 😕
Server Log of that last API call
I tried using this and that actually worked.
Do you have an ARRAY field metadata type in this object metadata definition ?
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 ...
Sorry those two are PHONE and EMAIL field metadata type I was thinking about an atomic field metadata array not a composite one
Or could it maybe be expecting an array due to my custom fields?
Will update now
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
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"}
thanks, no array field 🤔
BTW: Let me say a big THANK YOU for your effort in trying to help me @stark epoch @inland kettle 🫶 !
Of course you're welcome @lilac shadow !
Will try to reproduce on my side once 1.0.2 is shipped
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 🤣 ?
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.
Indeed, in select and multi select field settings, you will see the API values
Complete fix:
{
"academicTitle": [],
"salutation": "HERR",
"formOfAddress": "DU",
...
}
Thanks for the update. I'm over the hump and can now continue the migration :-).