0

I have a civicrm-application that gets updates trough an external rest-api call. But there's something odd happening.

Request:
```
api_key=76d9f1d3h4c87c2465a8a305b6fe&key=487e30c9219952143657f779&json={"first_name":"Sebastian","last_name":"Vyaene","birth_date":"01-01-1992","gender_id":2,"custom_5":"B380-A003-G164-W878","custom_6":null,"custom_7":null,"preferred_language":"nl_NL","phone":"0477745678","custom_8":{},"custom_18":[],"contact_type":"Individual","sequential":1,"custom_14":0,"id":420564,"custom_10":0,"api.Address.create":{"contact_id":"$value.id","street_address":" ","postal_code":"9000","city":null,"location_type_id":1,"id":396363},"api.Email.create":{"contact_id":"$value.id","email":"[email protected]","id":426290},"api.Phone.create":{"contact_id":"$value.id","phone":"0477745678","id":101260},"api.Membership.create":{"contact_id":"$value.id","membership_type_id":1,"join_date":"2017-10-16","start_date":"2017-10-16","end_date":"2018-10-16","source":{},"custom_17":"B380-A003-G164-W878","id":362337}}&entity=Contact&action=create

``` this is an create action, but there's already an id present, so there should be an update. But as you can see in the response, the id is ignored and another contact is created, what is not the behaviour we want.

Response:

```

{"is_error":0,"version":3,"count":1,"id":481202,"values":[{"id":"481202","contact_type":"Individual","contact_sub_type":"","do_not_email":"0","do_not_phone":"0","do_not_mail":"0","do_not_sms":"0","do_not_trade":"0","is_opt_out":"0","legal_identifier":"","external_identifier":"","sort_name":"Vyaene, Sebastian","display_name":"Sebastian Vyaene","nick_name":"","legal_name":"","image_URL":"","preferred_communication_method":"","preferred_language":"nl_NL","preferred_mail_format":"Both","hash":"0326647eddd86831d8e1454926e8a2c5","api_key":"","first_name":"Sebastian","middle_name":"","last_name":"Vyaene","prefix_id":"","suffix_id":"","formal_title":"","communication_style_id":"","email_greeting_id":"1","email_greeting_custom":"","email_greeting_display":"","postal_greeting_id":"1","postal_greeting_custom":"","postal_greeting_display":"","addressee_id":"1","addressee_custom":"","addressee_display":"","job_title":"","gender_id":"2","birth_date":"1992-01-01","is_deceased":"0","deceased_date":"","household_name":"","primary_contact_id":"","organization_name":"","sic_code":"","user_unique_id":"","created_date":"2018-08-20 10:04:48","modified_date":"2018-08-20 10:04:48","api.Address.create":{"is_error":0,"version":3,"count":1,"id":396363,"values":[{"id":"396363","contact_id":"481202","location_type_id":"1","is_primary":"1","is_billing":"0","street_address":" ","postal_code":"9000","manual_geo_code":"0"}]},"api.Email.create":{"is_error":0,"version":3,"count":1,"id":426290,"values":[{"id":"426290","contact_id":"481202","location_type_id":"","email":"[email protected]","is_primary":"","is_billing":"","on_hold":"","is_bulkmail":"","hold_date":"","reset_date":"","signature_text":"","signature_html":""}]},"api.Phone.create":{"is_error":0,"version":3,"count":1,"id":101260,"values":[{"id":"101260","contact_id":"481202","location_type_id":"","is_primary":"","is_billing":"","mobile_provider_id":"","phone":"0477745678","phone_ext":"","phone_numeric":"","phone_type_id":""}]},"api.Membership.create":{"is_error":0,"version":3,"count":1,"id":362337,"values":[{"id":"362337","contact_id":"481202","membership_type_id":"1","join_date":"2017-10-16","start_date":"2017-10-16","end_date":"2018-10-16","source":"Array","status_id":"2","is_override":"","owner_membership_id":"","max_related":"","is_test":"0","is_pay_later":"0","contribution_recur_id":"","campaign_id":""}]}}]}

``` 

Request Id: 420564 Response Id: 481202

I've looked at the call for hours and i can't find the problem. Anyone else who can help?

I'm currently on 4.6.36 and drupal 7.59. But as a test i upgraded to 5.2.1 and the same problem occures.

1
  • The request string looks correct. Can you share a part of the code where you call the rest api? Aug 20, 2018 at 10:14

1 Answer 1

1

The snippet looks correct to me, Can you try using 'contact_id' instead of 'id' as sometimes it did work for me. I am having hard time to recollect the scenario why i had to use 'contact_id' over 'id'.

Cheers

Pradeep

1
  • That doesn't help unfortunately. Aug 20, 2018 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.