CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Creating new contact with address via API
Pages: [1]

Author Topic: Creating new contact with address via API  (Read 428 times)

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Creating new contact with address via API
July 04, 2014, 05:33:43 am
I'm trying to create a new individual with an address via the php API.

The API explorer for Contact Create shows address fields, but my attempts to specify address fields seem to be ignored although the contact is created. Is it possible to create the address directly?  (If not, why do these show as available fields in the API?)


DaveFF

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 5
  • Developer at Future First
    • Future First
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.34
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Creating new contact with address via API
July 18, 2014, 01:20:48 am
Try doing a second API call, to Address Create, passing the contact ID of your newly created contact as the contact_id parameter.
Do Not Contact Until extension: https://civicrm.org/extensions/do-not-contact-until
Organisation Name De-duplicator extension: https://civicrm.org/extensions/organisation-name-de-duplicator

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Creating new contact with address via API
July 18, 2014, 04:53:39 am
you can chain the api calls, put an extra params['api_address_create'] = array (street and stuff)

it takes care of assiging the contact_id directly
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Re: Creating new contact with address via API
July 22, 2014, 09:37:53 am
Thanks - chaining solved my problem.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Creating new contact with address via API

This forum was archived on 2017-11-26.