API3
david at March 25th, 2015 13:10 — #1
Hi,
When the lead has the mobile phone number, it comes through with no problem.
When the lead doesn't have the mobile phone number, it gets me this error message:
{"status":400,"message":"Invalid request data","error_name":"invalid_request_data","error_message":"A validation error has occurred","errors":{"phones":"Required field, '{\"type\"=\u003e\"mobile\", \"value\"=\u003e\"\"}', is missing"}}
Is there a way to make that field 'optional'?
Any suggestion?
Thanks!
pete_onepagecrm at March 25th, 2015 15:19 — #2
Hi @david, that is strange, the phones field is an optional field, but if you include it, it will expect a number.
Are you posting a request like this?
({
'first_name' => 'Peter',
'last_name' => 'Armstrong',
'phones' => [{
'type' => 'mobile',
'value' => '' }]
})
If so, change it to something like this:
({ 'first_name' => 'Peter',
'last_name' => 'Armstrong' })
Leave out the phone field all together and it should work fine.
That should sort you out.
Let me know if there's anything else.
david at March 25th, 2015 15:33 — #3
Hi Pete,
In fact, it's done dynamically with some kind of template.
So, the template is static as below, and our system injects data to each
field, which implies that the mobile field should be there all the time.
Any thoughts?
Thanks!
{
"first_name": "{$params.first_name}",
"last_name": "{$params.last_name}",
"company_name":"{$params.company}",
"emails": [
{
"type":"work",
"value":"{$params.email}"
}
],
"phones": [
{
"type":"work",
"value":"{$params.phone}"
},
{
"type":"mobile",
"value":"{$params.mobile}"
}
],
"address_list": [
{
"address":"{$params.street}",
"city":"{$params.city}",
"country_code":"{$params.country_code}",
"state":"{$params.state_code}",
"zip_code":"{$params.zip}"
}
],
"lead_source_id":"{$params.lead_source}",
"background": "{$params.description|replace:'"':'\"'|regex_replace:"/[\r\n]/" : "\\n"}",
"partial" : "{$params.partial}",
"tags": ["{$params.tag}"]
}
pete_onepagecrm at March 25th, 2015 16:00 — #4
Hmm, at the moment all I can suggest is to add in the phones / emails / urls fields to the json after the rest of the contact information has been built, if that data exists.
What language are you using?
Only sending the data that you actually have would also keep your requests slightly faster - probably negligible but every little counts these days.
We could change the API on our side to discard these fields if empty, but I won't be able to make this change that quickly.
david at March 26th, 2015 14:38 — #5
Thanks, Pete. I managed to resolve the issue with a logic to inject a default dummy number when the mobile phone data is null.
Powered by Discourse, best viewed with JavaScript enabled