Hot answers tagged

15

Hopefully a new release will be made for the API Key extension soon. Here are detailed instructions for creating one manually without needing to get access to your database through phpMyAdmin, mysql on the command line or some similar MySQL database administration tool. Usually it is a good idea to create a special separate contact for each service that ...


9

I'm pretty certain you can't get a checksum from the standard API. However, you should write (or commission) an extension to provide a checksum API. The API would basically be a wrapper around the code that DaveD suggested, and you can read documentation here on how to use Civix to generate an API in your extension.


9

I have never seen the checksum available in the API. I have successfully obtained it programmatically though with code similar to: $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contact_id); (This snippet is adapted from core code in CRM/Utils/Token.php)


8

Whether or not https is used would be dependent on the CMS, but this is certainly recommended. Other than making sure the Access AJAX Api permission is set up for a particular CMS user, you will also need to pass a user api key that is assigned to the CiviCRM contact record associated with that CMS user. Details at: http://wiki.civicrm.org/confluence/...


8

The REST API requires that you specify the site key and an API key. Details can be found here.


7

I would recommend you to use post instead of get to communicate with the rest api, both because it would allow you to avoid having the keys "in clear" in the get url (and therefore written in the log an so on), but also because you don't have to deal with url encoding of the parameters. btw, you don't have to put the param in the json most of the time, so ...


4

I needed this exact functionality, so I wrote the extension that provides it, com.megaphonetech.checksums. I used Coleman's comment above as my spec :)


4

Please, do not put the api_key nor key into the get parameter, to they don't end up in logs and other places, they are better as a post param. As for your question, you can have json="{'id':2..."} as a param, ie json encode the whole contact and put as as a string param into a (post) json param You might be safer to return only the modified param, as some ...


4

I just figured it out: &received_date[BETWEEN][]=2017-12-01&received_date[BETWEEN][]=2017-12-02


3

You need to know the custom field ID of the field in question. If the ID is 14, you can use: <www_path>?entity=activity&action=create&activity_id=0&target_contact_id=0&custom_14=myvalue In general, if you're asking these sorts of questions, you can answer them best by using the API explorer: Help menu > Developer > API Explorer. You ...


3

@samuelsov got me going in the right direction, along with trial and error from the documentation: This returns all related phone records for the given contact_id: entity=Contact&action=get&contact_id=1234&api.Phone.get[values] And you can filter the chained API call too, for example all related phone records with a phone_type_id of 2: entity=...


3

As kainuk mentioned, you don't have the right syntax for the json field, i needs to be json= instead of json: http://www.mysite.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=create&api_key=(myAPIkey)&key=(mySiteKey)&json={“contact_type":"Individual","first_name":"Tester","last_name":"Yolanda"} (it needs to be ...


2

Not natively, you would need to write a custom extension to do the relatively simple task of converting array output from the api to csv output.


2

When the Contact Get REST api is triggered, I can see that the permission clause for the ACL is being generated from the whereClause() funcion of CRM_ACL_API. Here a contactId(previously passed as NULL) is fetched from the session (logged in user id) and the contact from api_key is actually not taken into account. Hence a 0 is set for ContactId and ACL ...


2

To clarify, they are two ways of accessing the api over the net, the REST interface (that uses the keys) and the ajax one (that is used for the front end js, and doesn't need the keys) So if it's client js, the authentication is done through the CMS, so via the cookie session. You shouldn't use the keys. What we recommend is to always use POST when we use ...


2

it's simply based on the name of the action, it has to be starting with get, so get, getsingle and so on are considered readonly and accepts over GET, the rest should be POST. this being said, not sure using the rest api is the best option, you might want to use the 'normal' ajax backend and the js wrapper part of civi that takes care of calling the api the ...


2

While REST isn't available (the demo DB is reset daily, and the demo account does not have a publicly accessible API key), you can explore the CiviCRM API using the API explorer once logged in. http://d45.demo.civicrm.org/civicrm/api/explorer


2

This isn't possible, sorry. Could you say a bit more about what you're trying to achieve? I'm not sure how useful it is to do REST calls against a demo site.


2

The wiki page http://wiki.civicrm.org/confluence/display/CRMDOC/REST+interface pretty much describe what you could do with rest. From the wiki page : Before the REST interface can be used, two things have to be set up: You need to know your site key which can be found in the civicrm.settings.php file labelled CIVICRM_SITE_KEY. You will need ...


2

It's probably easiest to use a wrapper around that call that hide the complexity. You can copy api/class.api.php into your client server and use it as indicated in the example in the source: $api = new civicrm_api3 (array ('server' => 'http://example.org', 'api_key'=>'theusersecretkey', ...


2

Option one: API will be the best option Please use this link in your instance http://localhost/abc/civicrm/api/explorer or http://d46.demo.civicrm.org/civicrm/api/explorer#explorer you will get JSON output


2

What you are asking is "How do I send a POST request with PHP?". See the following stackoverflow question: https://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php .


2

I believe there is currently a bug. I have submitted a bug report: https://issues.civicrm.org/jira/browse/CRM-20582 When I ran into my issue, I was told: "If you need a quick fix that doesn't involve granting more permissions than users ought to have, take a look at https://docs.civicrm.org/dev/en/master/hooks/hook_civicrm_alterAPIPermissions/."


2

You need to use the extension which creates an 'API Key' tab on the contact record. https://github.com/cividesk/com.cividesk.apikey/archive/v1.0.zip JMC


2

In the end, I was only able to make it work by using array notation. Some examples below. All these worked in the array notation on the right, but not in the object notation on the left: "options": {"limit":"100","offset":"100"}  --->  "options[limit]": "1","options[offset]": "100""custom_1": {"IS NOT NULL":"1"}  --->  ...


2

CiviCRM allows you to send api params in POST by encrypting the params in json. Here is an example on how you can build api params used in REST call http://www.domain.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=create&api_key=userkey&key=sitekey&json={"contact_type":"Individual","first_name":"test","last_name":"test","...


2

@pfigel in chat.civicrm.org responded that this is possibly a problem with encoding. This works for him: curl -X POST 'http://civicrm.example.com/sites/all/modules/civicrm/extern/rest.php' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'api_key=hunter2&key=hunter2&entity=Contact&action=create&json=%7B%...


2

CiviCRM provides api for each entity. Each entity has its own parameter. You can use API explorer to find how params are build and need to send through rest api. The API explorer screen provides detailed information about using various method of using api to perform CRUD operation on CiviCRM. While using rest api you will need to pass Site key (stored in ...


1

Not everyone else use only the json, I find it easier to read and fix to use separate params ;) I think the error is on the json you provide is not correct. Instead of: ["sequential"=>1,"return"=>"id,do_not_mail","external_identifier"=>777] it should be {"sequential":1,"return":"id,do_not_mail","external_identifier":777}


1

All you need to do is follow the documentation, as suggested by Karin. When you save the API key in the setup screen, the extension will make API calls to SparkPost and create a callback. Whenever a bounce occurs, SparkPost triggers this callback and CiviCRM can then process the bounce event accordingly. As also indicated in the documentation, only ...


Only top voted, non community-wiki answers of a minimum length are eligible