4
votes
How to see the SQL generated by Api4 calls?
Alternatively ...
fire up api4 explorer and prepare your query. Make sure to ✔ the debug option
execute the query
click the 'Debug' tab next to the 'Result' tab
4
votes
Accepted
Finding contacts without relationships (API)
Yes you can! I fiddled with the APIv4 Explorer a bit and came up with this:
The trick is to join onto RelationshipCache with the relationship type(s) you are wanting to exclude (note that the double ...
4
votes
Accepted
Do strings used in API version 4 need to be escaped?
Yes, all strings will be escaped automatically by the CiviCRM code.
3
votes
Accepted
Delete On_Hold emails and reassign Primary Email
Civi will set another address as Primary if you use its tools to delete but it can't do that if you rip data out from under its feet.
Deleting things directly from the database is usually a bad idea! ...
3
votes
Accepted
Recurring Contributions count not match: "Find Contributions" vs API4 Contribution::get
Can you also add same filters in api4 as Find Contribution
is_template = 0
contribution_status_id = Completed
3
votes
Accepted
Is the use of API4 already recommended?
See https://lab.civicrm.org/dev/core/-/issues/2486 but I believe all of those things are deprecated anyway (or on the way to being deprecated) and the idea is to use Order and Payment: https://docs....
3
votes
Accepted
API4 PHP Fatal error Uncaught API_Exception Authorization failed
Because you're using a manual way to bootstrap civi (as opposed to e.g. running your script with cv scr --user=admin), you need to either add code in there to also "log in" as a user, or you ...
3
votes
api4: get(FALSE) vs get()->setCheckPermissions(FALSE): which is preferred?
Core tends to use the short form but both are equally valid. The short form was introduced later just because it comes up so often that you want to set it to false.
3
votes
Accepted
Invalid field 'contact_id.is_deceased' Apiv4
That backtrace seems to point to this change as the culprit, however after several attempts I've been unable to reproduce that error. We can continue discussion on this issue: https://lab.civicrm.org/...
3
votes
Creating extensions for custom tables
It sounds like what you are asking about are Custom Field Groups.
A Custom Field Group is generally not accessible from the API as an entity. Instead, you access the Custom Fields within the Custom ...
3
votes
Api get all option within sub entity
The best way to learn how to use the API is the Api Explorer which is built into CiviCRM (find it in the Support -> Developer menu. It will write the following code for you:
$optionValues = \Civi\...
3
votes
Accepted
Retrieving Contact information with API4 Inside the module
Try changing \Civi\Api4\Contact::get(TRUE) to \Civi\Api4\Contact::get(FALSE)
The TRUE/FALSE parameter is a short-hand for checkPermissions. The default in Api4 is that permissions are checked but you ...
3
votes
Accepted
Can rename(AS) a column/field from SELECT using APIv4
There was a long discussion about this at https://lab.civicrm.org/dev/core/-/issues/3738
which resulted in a new $result->rekey() method added to the next beta (5.74).
See https://github.com/...
3
votes
Accepted
API 4 Explorer: Adding my custom action to existing Api4 Action from Civi
I was apparently missing classloader in info.xml. Updated it and is now working.
2
votes
How to see the SQL generated by Api4 calls?
You can do this from the API explorer if you use your browser's dev tools.
fire up api4 explorer and prepare your query. Make sure to ✔ the debug option, and un-✔ the check permissions box.
open your ...
2
votes
Accepted
Best (api4) way to chain save a contact so that the email updates, without creating a new one?
I got what I needed by including the email id ("id":2) in the records chain property:
crmApi4('Contact', 'save', {
records: [{"id":2, "first_name":"Mike"}],
...
2
votes
Accepted
How to get Target Contacts from Api4 Activity.get call?
For joining explicitly by adding an ActivityContact join then a Contact join instead of just a Contact join with "Using ActivityContact" in the explorer, I think it's just the Contact join ...
2
votes
Searchkit Buttons not working
Problem a result of using Shoreditch as Civi theme. Same problem exhibited when using API Explorer UI.
SearchKit and API Explorer both use bootstrap theme which seems to have conflict with ...
2
votes
Accepted
Make API queries - two methods failing
For your cv call either turn off the permission check or specify a user to run with.
So either:
<?php
$result = civicrm_api4('Contact', 'get', [
'checkPermissions' => FALSE,
'...
2
votes
Using API4 to get contact based on email match
So @Demerit's answer above was exactly what I needed to understand how to connect the two tables together (email table and contact info table). I am posting my answer for other noobs that are trying ...
2
votes
Odd REST API result
Can you try with a LIKE 'CLC' rather than '='? This might help as the contact_sub_types are stored with the weird CRM_Core_DAO::VALUE_SEPARATOR around the values?
2
votes
How to get Price Sets related to a Contribution Page using API 4
Unfortunately, there isn't a way to get the price set used for the contribution or event page. The link is stored in civicrm_price_set_entity, with entity_table set as civicrm_contribution_page or ...
2
votes
APIv4 Base URL for external applications
How about
http://192.168.100.168:8166/?civiwp=CiviCRM&q=civicrm/ajax/api4/Relationship/get
You can check the REST tab in API4 explorer for correct url
2
votes
Accepted
Get uploaded file full URL via API v4
With the help of Lars SG's links. I created a, PHP 8, helper function to get a URL based on a file ID provided by the API.
function se_45209_get_entity_image_url( int $entity_id, int $file_id ): ...
2
votes
Accepted
Use Order API or use APIv4?
The advice to use Order API is still sound and should be followed. As of this post it has not yet been ported to APIv4 so you'll have to use v3 until that work is complete. Progress on the port can be ...
2
votes
Get Phone or Email with API4 not possible?
This looks like a 2-parter so I'll just answer your first question about how to fetch all emails & phones for a contact. Please start a new post for your curl question.
APIv4 does fetch all fields ...
2
votes
civicrm_api4: How do I create a Contact with Tags (EntityTag)?
Apply this patch Jeremy -> this is fixed in the D10 version of CiviCRM Entity, but the D9 version requires this backport by Pradeep:
root@46c1218044c0:/var/www/drupal/web/sites/default/modules/...
2
votes
CiviCRM Wordpress Critical Error Upon Event Registration
It sounds like you don't have civicontribute enabled.
2
votes
Accepted
Use APIv4 to change Case Manager role and to add another role as well
For the first part did you try creator_id?
For the second one yes just do it after. Relationship.create with a case_id parameter.
EXAMPLES (for clarity):
// PHP
// Create a NEW CASE with CLIENT ...
1
vote
Accepted
retrieve event registration link with api v4
There isn't any option in the API to generate registration link, the code you are using should create the correct link
$id = $event['id'];
$reglink = CRM_Utils_System::url('civicrm/event/register', &...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
apiv4 × 55api × 17
wordpress × 10
contacts × 5
rest × 4
civievent × 3
email × 3
extension × 3
custom-fields × 2
permissions × 2
php × 2
cron × 2
civicrm-entity × 2
searchkit × 2
api4 × 2
drupal × 1
civicontribute × 1
civimail × 1
civimember × 1
upgrade × 1
error × 1
civicase × 1
groups × 1
contribution-page × 1
recurring-contributions × 1