API3
awicrm at April 28th, 2020 05:34 — #1
Hi,
I tried creating new contact using the API, this is the code in python:
r = requests.post(url + '/contacts.json', auth=my_auth, data =
{
'first_name': 'test',
'company_name': 'tes company',
'phones': [{'type': 'work', 'value': '08137829387'}],
"address_list": [{
"address": "Jalan gulingan 15",
"city": "Semarang",
"country_code": "ID",
"type": "delivery"
}],
'status_id': '5ea7b918ccd15a5259504b34',
'owner_id': '5ea7b9111090707b2500d950',
'custom_fields': [
{
'custom_field': {'id': '5ea7cf0accd15a525950a7db'},
'value': '1068',
},
]
}
)
It didn't work, with the following error message:
{"status":400,"message":"Invalid request data","error_name":"invalid_request_data","error_message":"A validation error has occurred","errors":{"address_list":"Must be array with at most one item"}}
Please help and advise, thanks.
awicrm at April 28th, 2020 20:33 — #2
Never mind, it was my mistake, instead of 'data', I should have used 'json' as the parameter, the post request should be like this:
r = requests.post(url + '/contacts.json', auth=my_auth, json =
{
'first_name': 'test',
'company_name': 'tes company',
'phones': [{'type': 'work', 'value': '08137829387'}],
"address_list": [{
"address": "Jalan gulingan 15",
"city": "Semarang",
"country_code": "ID",
"type": "delivery"
}],
'status_id': '5ea7b918ccd15a5259504b34',
'owner_id': '5ea7b9111090707b2500d950',
'custom_fields': [
{
'custom_field': {'id': '5ea7cf0accd15a525950a7db'},
'value': '1068',
},
]
}
)
johnmag at April 29th, 2020 06:05 — #3
Hi there,
Great to hear you got it solved.
Thanks for getting in touch.
All the best,
John
Powered by Discourse, best viewed with JavaScript enabled