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) »
  • Different behaviour api explorer and drush cvapi
Pages: [1]

Author Topic: Different behaviour api explorer and drush cvapi  (Read 755 times)

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Different behaviour api explorer and drush cvapi
October 02, 2014, 04:04:39 am
I have a strange problem with the api on a certain CiviCRM instance (using v. 4.5.0).

I have custom fields on Address. When I use the API explorer to get an address given the address-ID and using the custom field in the return parameter, I get the expected result:
Code: [Select]
  {
    "is_error":0,
    "version":3,
    "count":1,
    "id":1794,
    "values":[{
      "id":"1794",
      "custom_12":"1",
      "custom_12_1":"1",
      "custom_45":"JLKSJFKADJSFLKADJS",
      "custom_45_1":"JLKSJFKADJSFLKADJS"
    }]
  }

Now the API explorer also shows the drush command:

Code: [Select]
drush cvapi Address.get sequential=1 return="custom_45" id=1794
But when I enter this drush command, I don't get the custom values. I only get:

Code: [Select]
Array
(
    [is_error] => 0
    [version] => 3
    [count] => 1
    [id] => 1794
    [values] => Array
        (
            [0] => Array
                (
                    [id] => 1794
                )
        )
)

The strange thing is that I cannot reproduce this behaviour on a clean install. So I guess something is wrong with my configuration.

Is it possible that drush doesn't have the correct permissions to see the custom fields? And if so, can I check this?

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: Different behaviour api explorer and drush cvapi
October 02, 2014, 06:08:33 am
I found out what caused this behaviour!  :D

It is a permission problem. It seems that it does work when I grant the 'CiviCRM: access all custom data' permission to the anonymous user.

Now I think this is a bug. I guess drush should always have the permission of access the custom data.

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: Different behaviour api explorer and drush cvapi
October 02, 2014, 06:46:37 am
Issue report: https://issues.civicrm.org/jira/browse/CRM-15410

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Different behaviour api explorer and drush cvapi
October 02, 2014, 08:44:23 am
Glad you got it working.
Note that the drush syntax being generated by the api explorer is pretty "rough" I just sort of threw it in there as an afterthought but didn't have time to write a proper shell syntax generator, so some of the more complex calls (e.g. api chaining) will come out wrong.
Try asking your question on the new CiviCRM help site.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Different behaviour api explorer and drush cvapi
October 02, 2014, 12:53:52 pm
Actually - I don't think it's a bug exactly - the trick with drush is to specify the user in the command - ie.

drush -u1

It might be that it needs documenting? Or ideally drush would add a message that warns you or something
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

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: Different behaviour api explorer and drush cvapi
October 06, 2014, 12:31:10 pm
drush -u 1 seems to work, indeed. Yet I find it strange that you need -u 1 to create a custom value, if anonymous users cannot create custom values, but you don't need it to create a new contact without anonymous users being able to create a contact.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Different behaviour api explorer and drush cvapi

This forum was archived on 2017-11-26.