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) »
  • New phone API w/ REST
Pages: [1]

Author Topic: New phone API w/ REST  (Read 2013 times)

David L

  • I post occasionally
  • **
  • Posts: 55
  • Karma: 2
New phone API w/ REST
May 29, 2011, 07:08:29 pm
Trying to figure out how to use the new Phone API with REST, but having no luck. I can't find any real documentation on the Address, Email, Phone and Website APIs anywhere - even http://api.civicrm.org/v3/ only has the deprecated Location API instead of the new APIs.

What would the url be for the phone API?

/civicrm/extern/rest.php?q=civicrm/phone/add doesn't work, neither does phone/create

And what params can be passed?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: New phone API w/ REST
May 29, 2011, 07:12:07 pm
Try the api explorer for REST syntax

http://sandbox.civicrm.org/civicrm/ajax/doc#explorer & the examples directory for php stuff

http://svn.civicrm.org/civicrm/branches/v3.4/api/v3/examples

There is a new chained syntax that is only in svn at the moment which you can use for multiple actions

http://svn.civicrm.org/civicrm/branches/v3.4/api/v3/examples/ContactCreate.php

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

David L

  • I post occasionally
  • **
  • Posts: 55
  • Karma: 2
Re: New phone API w/ REST
May 29, 2011, 07:31:04 pm
The explorer is a little buggy, try selecting phone, all the available fields are listed as 'undefined' so you have no idea how to use the api

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: New phone API w/ REST
May 29, 2011, 07:34:34 pm
You should just be able to add your variables to the string ie

function phone_create_example(){
$params = array(
  'contact_id' => 1,
  'location_type_id' => 6,
  'phone' => '021 512 755',
  'is_primary' => 1,
  'version' => 3,
);

= &contact_id=1&location_type_id=1 etc
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: New phone API w/ REST
May 29, 2011, 11:41:15 pm
Make sure you select v3 for Phone on the API explorer, and select 'getfields' with action. You will get a list of all the fields available in the Phone API.
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New phone API w/ REST
May 30, 2011, 02:39:41 am
Ahhh,

Just realised that getfields has been fixed and follow the api convention (putting under values) and that ajax/doc doesn't.

@David, could you create an issue and assign it to me, I'll fix for the next version.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

David L

  • I post occasionally
  • **
  • Posts: 55
  • Karma: 2
Re: New phone API w/ REST
May 30, 2011, 09:41:47 am
Created the issue http://issues.civicrm.org/jira/browse/CRM-8232 but I cannot assign it to you, maybe I don't have permissions to do that.

There is major need for documentation on REST API v3.

The official documentation http://wiki.civicrm.org/confluence/display/CRMDOC40/REST+interface is still for v2

Personally I just spend two hours trying to get v3 to work for me with (non-AJAX) REST, all I kept getting was 'Unknown Function Invocation' errors, even when using URLs generated directly by the API explorer, so I just gave up and went back to v2 instead, which works.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: New phone API w/ REST
May 30, 2011, 10:42:57 am
I agree that documentation is required, and it would be really helpful if you would assist? I use v3 with the REST and do not get the problems with the function invocations, but I am sure Xavier, Eileen and I could assist you?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New phone API w/ REST
May 31, 2011, 01:02:03 am
Could you try on the sandbox and post the urls you tried ?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New phone API w/ REST
May 31, 2011, 01:12:29 am
Quote from: David L on May 29, 2011, 07:31:04 pm
The explorer is a little buggy, try selecting phone, all the available fields are listed as 'undefined' so you have no idea how to use the api

Fixed, thx (to backport, copy in your install this file)
http://svn.civicrm.org/civicrm/branches/v3.4/templates/CRM/Core/AjaxDoc.tpl
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • New phone API w/ REST

This forum was archived on 2017-11-26.