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) »
  • Getting PriceSet of one event via REST api
Pages: [1]

Author Topic: Getting PriceSet of one event via REST api  (Read 822 times)

CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Getting PriceSet of one event via REST api
July 15, 2013, 09:15:49 am
I am trying to get a PriceSet from one event via REST api, but I don't succeed.

Getting all pricesets is not a problem
/sites/all/modules/contrib/civicrm/extern/rest.php?entity=PriceSet&action=get&debug=1&sequential=1&json=1&api_key={yoursitekey}&key={yourkey}

A result of one Priceset is:
Quote
   {
      "id":"4",
      "name":"test_2",
      "title":"Test  2",
      "is_active":"1",
      "extends":"1",
      "is_quick_config":"1",
      "is_reserved":"0",
      "entity":{
         "civicrm_event":["2"]
      }

But then I get into trouble, how would I get only PriceSets from Event: 2  via Rest API?

If I use "entity" it overrides the main "entity" parameter.
I also tried urls with "entity_table", but I could not get it to work.

How could I get only PriceSets from 1 event via Rest API?

(It's only to know if they exist so, whether I should update or add event fees to an import script)
« Last Edit: July 15, 2013, 09:19:01 am by CatorgHans »

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Re: Getting PriceSet of one event via REST api
August 21, 2013, 01:02:37 am
Not sure if it helps but you may divide it into two different API calls.

First, you ask for the event (Event / get):
/sites/all/modules/contrib/civicrm/extern/rest.php?entity=Event&action=get&id=1&debug=1&sequential=1&json=1&api_key={yoursitekey}&key={yourkey}

And you take the value for financial_type_id:
Quote
{
   "is_error":0,
   "version":3,
   "count":1,
   "id":1,
   "values":[{
      "id":"1",
      "title":"Congreso sobre Pena de muerte",
      "event_title":"Congreso sobre Pena de muerte",
      "event_type_id":"1",
      "participant_listing_id":"2",
      "is_public":"0",
      "start_date":"2013-08-21 09:47:00",
      "event_start_date":"2013-08-21 09:47:00",
      "is_online_registration":"0",
      "event_full_text":"This event is currently full.",
      "is_monetary":"1",
      "financial_type_id":"4",
      "is_map":"0",
      "is_active":"1",
      "fee_label":"Event Fee(s)",
      "is_show_location":"1",
      "default_role_id":"1",
      "is_email_confirm":"0",
      "is_pay_later":"0",
      "pay_later_text":"I will send payment by check",
      "is_partial_payment":"0",
      "is_multiple_registrations":"0",
      "allow_same_participant_emails":"0",
      "has_waitlist":"0",
      "is_template":"0",
      "created_id":"3",
      "created_date":"2013-08-21 09:48:09",
      "currency":"EUR",
      "is_share":"0",
      "contribution_type_id":"4"
   }]
}

In this case, financial_type_id is 4.

Then, you ask for the price set with this financial_type_id:
/sites/all/modules/civicrm/extern/rest.php?entity=PriceSet&action=get&financial_type_id=4&debug=1&sequential=1&json=1&api_key={yoursitekey}&key={yourkey}

Does it helps?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Getting PriceSet of one event via REST api

This forum was archived on 2017-11-26.