Add Call Log to Contact via API

Hi!
SuiteCRM Version 7.14.2
Using API V8

The case is that I’m able to add Call Log via API to Leads and Accounts but I’m not able to add Call Log to Contacts.

In fact when I add Call Log via API it appears in Calls:


But it doesn’t appear in on Contact page.

I found that when I will edit Call Log (from Calls) and save it without making any changes Contact is assigned


and it shows up in Hostory or Activity on Contact page.

I believe that I need to trigger refresh / reindex on SuiteCRM side but how to do this?
Below is my example request that I’m sending:

POST
https://XXXXXXXXXXXXX/Api/V8/module
{
    "data": {
    	"type": "Call",
        "attributes": {
        	"name": "Subject Call'a Nowego",
            "description": "Description Call'a Kolejnego",
            "duration_hours": "0",
            "duration_minutes": "15",
            "status": "Held",
            "direction": "Outbound",
            "date_start": "2024-01-11 19:15:00",
            "date_end": "2024-01-11 19:15:00",
            "parent_type": "Accounts",
            "parent_id": "bd3026f8-9ed8-e496-a122-65a005138a78"
            }
    }
}

The relationship between the two modules is missing. If you are in the UI, (probably) that is an extra step that happens when the bean saves. When using the API I expect that you are supposed to create it separately. I don’t use the API so I don’t know much about this, but you should find examples of creating a record in the relationship table.

That is exacly what I suspect. It is quite similar to object state snapshot that needs to be saved and reloaded (refreshed).

So the question still is how to add Call Log to Contact via API.

I don’t know, but I would start by finding out which table it is in the DB, probably calls_contacts or contacts_calls or something like that. If you don’t find mentions of calls, look for “activities”.

Then after you know the table, practice adding records to that table in the DB until the call shows in the contact’s log. After that, try doing the same creation from the API (an insert into the relationship table).

This should definitely be added to github for v7 as an issue/bug, and PR, when code available.

I’m not so sure, @chris001

Wouldn’t it be better to keep API operations more atomic, each doing only one thing?

Sometimes these SuiteCRM logic hooks firing under the hood create a real mess. I would prefer to keep things simple and do the relationships I want manually, to keep everything under control.

This is arguable, of course, and I don’t even use this API, but my instinct tells me it would be better this way.

Both would be of use depending on developer preference. We can have both. A flag parameter on the API calls would default to “atomic API operations”. Turn on the flag and you get “API auto creates relationships”. The best of both worlds.

1 Like

Iam push calllog for respective contact the api getting success reponse but the data not have in history section

this is curl
curl -X POST
http://abc.com/scehub/Api/V8/module
–header ‘Accept: /
–header ‘User-Agent: Thunder Client (https://www.thunderclient.com)’
–header ‘Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJjZjA2YzYyMC1kZTYyLWMzOGQtYjc4Ny02NTA0OGU0ODU3MDAiLCJqdGkiOiIyNjFlMmVjMDBhOGE3ODM1NDk5YmE4YWVkZTZmYjliNDM1YTRkZDM1OTFjNDliYzg4ZTc4MDRhZWZjYjZjNGZhYTEzNDRhZTA5MWMyMTQ4MSIsImlhdCI6MTcxMjIwODE1OS4xMDkyMDUsIm5iZiI6MTcxMjIwODE1OS4xMDkyMTUsImV4cCI6MTcxMjIxMTc1OS4wNDgzMDMsInN1YiI6IjYwMzEwNDZjLWQ3YWEtYzQwZS02N2ViLTUxOGIzN2QzNzI4MSIsInNjb3BlcyI6W119.Z1ug0R76COAcEY82dJz80HPlCpP5gMqocd-Lof69S2bi-3fTjFxDKcgdBQsgNo_3RNrkN2a8o9luYfLHjsLcWLdbmE8lYxN2HHwp9Sb9X9_UJ7ajbEZcpS54YOl1bnN4gNgxDXbDm-’
–header ‘Content-Type: application/json’
–data-raw ‘{
“data”: {
“type”: “Call”,
“attributes”: {
“name”: “Call from 128 to 90421364001234”,
“date_start”: “2024-04-03 12:56:55”,
“date_end”: “2024-04-03 13:02:49”,
“duration_hours”: “00”,
“duration_minutes”: “33”,
“contacts”: “9042136400”,
“status”: “Not Held”,
“direction”: “OUTBOUND”,
“parent_type”: “Contacts”,
“contact_id”: “a6933994-86ac-29c6-0bc6-660e38c72e08”,
“parent_id”: “a6933994-86ac-29c6-0bc6-660e38c72e08”,
“assigned_user_id”: “vnssuitecr_agent01”,
“description”: "\nRecording file URL: "
}
}
}’

below the api reponse

getting empty

but in call section

It is a matter of adding relation after adding new call log.

yes i need to add it the respective contact section is not in history but in call module is added. need support api push for history of the activity

That is what I wrote :slight_smile:
After adding call via api you need to send second request via api and create relation with contact.
Held call will become “History” and Not Held call will become “Activity”.

Give me api endpoints please. Iam stuggling around 3 weeks.

If it helps, here’s an example of creating accounts->contacts relationship. I would think you could follow this and create a call->contacts relationship.

still not working @pstevens Iam suiteCRM version

this iam using before create call log for respective contact

Relationship contact link to account below the api
curl -X POST
http://dooctiapi.online.in:89/scehub/Api/V8/module/Accounts/b916445d-e1aa-5667-20d8-660f87727262/relationships
–header ‘Accept: /
–header ‘User-Agent: Thunder Client (https://www.thunderclient.com)’
–header ‘Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJjZjA2YzYyMC1kZTYyLWMzOGQtYjc4Ny02NTA0OGU0ODU3MDAiLCJqdGkiOiIyZDM2YWRjOWU3MDk3OWNmOWVhNzk5NTZlMDczYjgzMDJjMGM5NTYzYWUyNDc3NjIyYzM4ZmQ5NzEzMjFlNzY2NzZlOWNiYWE5NWYyYmU3OCIsImlhdCI6MTcxMjI5NTUxMy43NTY1MjEsIm5iZiI6MTcxMjI5NTUxMy43NTY1NCwiZXhwIjoxNzEyMjk5MTEzLjY5OTIyNCwic3ViIjoiNjAzMTA0NmMtZDdhYS1jNDBlLTY3ZWItNTE4YjM3ZDM3MjgxIiwic2NvcGVzIjpbXX0.x-CHmh2KSklP_YRFgsR9DArzyeWCALsKDlwlJI9JFMO2c1llTb18t-3-4-VieVuY3A-xsh7vow5t0t86QSI55ag4lu7KmZCtWg3p_WhE7DwQzM1ICk-R1J4MHPVFPudGPPU_EwpJb4ej2G5SMBuOG_iJR5eaphVKRqd6a2jxyAzX-na6Wad3RqJRSwh_gEhHUadyt2b4IGGPu7f6eMbL2ppSx8K1m0XPzZn4FVv34NI3WkO1ExrlQTPH6S1YqiuB0AJ8BRSLH-wc1Q2aPueFCSR5gp-KCAqn0HNc253EX-sA8QWYXr5KQvRFt6vookH_lYeKhX7m37giYnHg36hmlQ’
–header ‘Content-Type: application/json’
–data-raw ‘{
“data”: {
“type”: “Contacts”,
“id”:“a6933994-86ac-29c6-0bc6-660e38c72e08”
}
}’

below the create call log api
curl -X POST
http://dooctiapi.online.in:89/scehub/Api/V8/module
–header ‘Accept: /
–header ‘User-Agent: Thunder Client (https://www.thunderclient.com)’
–header ‘Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJjZjA2YzYyMC1kZTYyLWMzOGQtYjc4Ny02NTA0OGU0ODU3MDAiLCJqdGkiOiIyZDM2YWRjOWU3MDk3OWNmOWVhNzk5NTZlMDczYjgzMDJjMGM5NTYzYWUyNDc3NjIyYzM4ZmQ5NzEzMjFlNzY2NzZlOWNiYWE5NWYyYmU3OCIsImlhdCI6MTcxMjI5NTUxMy43NTY1MjEsIm5iZiI6MTcxMjI5NTUxMy43NTY1NCwiZXhwIjoxNzEyMjk5MTEzLjY5OTIyNCwic3ViIjoiNjAzMTA0NmMtZDdhYS1jNDBlLTY3ZWItNTE4YjM3ZDM3MjgxIiwic2NvcGVzIjpbXX0.x-CHmh2KSklP_YRFgsR9DArzyeWCALsKDlwlJI9JFMO2c1llTb18t-3-4-VieVuY3A-xsh7vow5t0t86QSI55ag4lu7KmZCtWg3p_WhE7DwQzM1ICk-R1J4MHPVFPudGPPU_EwpJb4ej2G5SMBuOG_iJR5eaphVKRqd6a2jxyAzX-na6Wad3RqJRSwh_gEhHUadyt2b4IGGPu7f6eMbL2ppSx8K1m0XPzZn4FVv34NI3WkO1ExrlQTPH6S1YqiuB0AJ8BRSLH-wc1Q2aPueFCSR5gp-KCAqn0HNc253EX-sA8QWYXr5KQvRFt6vookH_lYeKhX7m37giYnHg36hmlQ’
–header ‘Content-Type: application/json’
–header ‘Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJjZjA2YzYyMC1kZTYyLWMzOGQtYjc4Ny02NTA0OGU0ODU3MDAiLCJqdGkiOiIzYWQzODUyYWE2MmQxNGFjZTdkZmU1MDU3MzgwZTk4M2JiZTQ3MjYwYzJjM2EwYjcwZDY0ODNiMDkzM2Y1ZmRjZDQ5YjA1Y2Q5OTYzYmI1NSIsImlhdCI6MTcxMjI5ODUxMy43Njc4MzUsIm5iZiI6MTcxMjI5ODUxMy43Njc4NDUsImV4cCI6MTcxMjMwMjExMy43MDI5NzcsInN1YiI6IjYwMzEwNDZjLWQ3YWEtYzQwZS02N2ViLTUxOGIzN2QzNzI4MSIsInNjb3BlcyI6W119.sOOoGvcrp5x0M5KbZm5KulDMWqVi0ZHzM8yMxNe6WLqJPsbO55JUf-r9kIVH3wLdCsEwkZvlcD5oMg0ktmYtWx11FVT9V-8a6_-ud3Ldy4XKUjP06fkHzvc-4gistWDhsuwYzcluTpDAhaDaBS_qURkNAV2YqbxZRCapT_GSjx3sL4mMSaQyB4xCeJWF432-5nKryJ0BzPrDsldvpkLWq7Y7f2OgIYyIEe7OwObvRPfpLV1-RLLixn9Pw5I777Ie0uyj46R9RnfMC2WyPA3iZkRGsOmmo37q18EQgs8O6oTFTU4heZ_rYumHPBncj6o7PjscU1HTgfiPlO7gR8fCLA’
–data-raw ‘{
“data”: {
“attributes”: {
“assigned_user_id”: “VNS Admin”,
“contacts”: “9042136400”,
“date_end”: “2024-04-03 13:02:49”,
“date_start”: “2024-04-03 12:56:55”,
“description”: “Recording file URL: https://nidoos.sgp1.com/cti_vnssuitecr_20221223/2024-04-03/1712129214.18650894.mp3”,
“direction”: “OUTBOUND”,
“duration_hours”: “00”,
“duration_minutes”: “33”,
“name”: “Call from 128 to 9042136400”,
“accounts”: “b916445d-e1aa-5667-20d8-660f87727262”,
“contact_id”: “a6933994-86ac-29c6-0bc6-660e38c72e08”,
“parent_type”: “Contacts”,
“status”: “Held”
},
“type”: “Call”
}
}’

  • Exactly the issue contact id doesn’t not mapped.Even Iam passing contact_id in payload.
    This is responce
    {
    “data”: {
    “type”: “Call”,
    “id”: “1c283457-59dd-acd4-9dcf-660fa5d3c877”,
    “attributes”: {
    “name”: “Call from 128 to 9042136400”,
    “date_entered”: “2024-04-05T07:17:00+05:30”,
    “date_modified”: “2024-04-05T07:17:00+05:30”,
    “modified_user_id”: “6031046c-d7aa-c40e-67eb-518b37d37281”,
    “modified_by_name”: “VNS Admin”,
    “created_by”: “6031046c-d7aa-c40e-67eb-518b37d37281”,
    “created_by_name”: “VNS Admin”,
    “description”: “Recording file URL: https://nidoos.sgp1.com/cti_vnssuitecr_20221223/2024-04-03/1712129214.18650894.mp3”,
    “deleted”: “0”,
    “created_by_link”: “”,
    “modified_user_link”: “”,
    “assigned_user_id”: “VNS Admin”,
    “assigned_user_name”: “”,
    “assigned_user_link”: “”,
    “SecurityGroups”: “”,
    “duration_hours”: “0”,
    “duration_minutes”: “33”,
    “date_start”: “2024-04-03T12:56:00+05:30”,
    “date_end”: “2024-04-03T13:29:00+05:30”,
    “parent_type”: “Contacts”,
    “parent_name”: “”,
    “status”: “Held”,
    “direction”: “OUTBOUND”,
    “parent_id”: “”,
    “reminder_checked”: false,
    “reminder_time”: “-1”,
    “email_reminder_checked”: false,
    “email_reminder_time”: “-1”,
    “email_reminder_sent”: “0”,
    “reminders”: “”,
    “outlook_id”: “”,
    “accept_status”: “”,
    “set_accept_links”: “”,
    “contact_name”: “”,
    “opportunities”: “”,
    “leads”: “”,
    “project”: “”,
    “case”: “”,
    “accounts”: “”,
    “contacts”: {},
    “aos_contracts”: “”,
    “users”: “”,
    “notes”: “”,
    “contact_id”: “”,
    “repeat_type”: “”,
    “repeat_interval”: “1”,
    “repeat_dow”: “”,
    “repeat_until”: “”,
    “repeat_count”: “”,
    “repeat_parent_id”: “”,
    “recurring_source”: “”,
    “reschedule_history”: “”,
    “reschedule_count”: “”,
    “calls_reschedule”: “”,
    “asterisk_server_ip”: “”,
    “asterisk_source_number”: “”,
    “asterisk_destination_number”: “”,
    “asterisk_call_duration”: “0”,
    “asterisk_logged_by_asterisk”: “0”,
    “asterisk_call_disposition”: “”,
    “asterisk_disposition_code”: “”,
    “asterisk_recording_link”: “”,
    “enjay_call_asteriskhost_c”: “”,
    “call_disposition_c”: “Sales_test”,
    “enjay_call_datetime_c”: “”,
    “enjay_call_destination_number_c”: “”,
    “enjay_call_direction_c”: “”,
    “enjay_call_disposition_c”: “”,
    “enjay_call_duration_c”: “”,
    “enjay_call_recordlink_c”: “”,
    “enjay_call_source_number_c”: “”
    },
    “relationships”: {
    “Accounts”: {
    “links”: {
    “related”: “V8/module/1c283457-59dd-acd4-9dcf-660fa5d3c877/relationships/accounts”
    }
    },
    “Calls_Reschedule”: {
    “links”: {
    “related”: “V8/module/1c283457-59dd-acd4-9dcf-660fa5d3c877/relationships/calls_reschedule”
    }
    },
    “Notes”: {
    “links”: {
    “related”: “V8/module/1c283457-59dd-acd4-9dcf-660fa5d3c877/relationships/notes”
    }
    },
    “SecurityGroups”: {
    “links”: {
    “related”: “V8/module/1c283457-59dd-acd4-9dcf-660fa5d3c877/relationships/SecurityGroups”
    }
    },
    “Users”: {
    “links”: {
    “related”: “V8/module/1c283457-59dd-acd4-9dcf-660fa5d3c877/relationships/created_by_link”
    }
    }
    }
    }
    }

You need to create relationship for Call not Account…

how @bartosz?

share endpoints for example curl

For example:

Of course you need to post correct json object that will contain information about relation target (Contacts, Accounts…) and its ID.

@bartosz Thank you so much its working…

its very valueable help once again thank you