Details
-
Type: Bug
-
Status: In Progress
-
Priority: Trivial
-
Resolution: Unresolved
-
Affects Version/s: 4.7.7
-
Fix Version/s: Unscheduled
-
Component/s: CiviCRM API
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Core Team Funds
Description
If you want to retrieve an address that does not have a contact ID (e.g. an address that is used for an event), and you want to use the HTTP-API for retrieving it, like e.g.
curl 'http://localhost/~johanv/chirocivi-dev1/sites/all/modules/civicrm/extern/rest.php/?api_key=MYAPIKEY&key=MYSITEKEY&debug=0&version=3&entity=Address&action=get&json=%7b"id":"408083"%7d&sequential=1'
you need to have the 'Access deleted contacts' permission. If you don't have this permission, the query that is issued, is this one: (just ignore the part about our custom fields)
SELECT a.id as `id`, a.contact_id as `contact_id`, a.location_type_id as `location_type_id`, a.is_primary as `is_primary`, a.is_billing as `is_billing`, a.street_address as `street_address`, a.street_number as `street_number`, a.street_number_suffix as `street_number_suffix`, a.street_number_predirectional as `street_number_predirectional`, a.street_name as `street_name`, a.street_type as `street_type`, a.street_number_postdirectional as `street_number_postdirectional`, a.street_unit as `street_unit`, a.supplemental_address_1 as `supplemental_address_1`, a.supplemental_address_2 as `supplemental_address_2`, a.supplemental_address_3 as `supplemental_address_3`, a.city as `city`, a.county_id as `county_id`, a.state_province_id as `state_province_id`, a.postal_code_suffix as `postal_code_suffix`, a.postal_code as `postal_code`, a.usps_adc as `usps_adc`, a.country_id as `country_id`, a.geo_code_1 as `geo_code_1`, a.geo_code_2 as `geo_code_2`, a.manual_geo_code as `manual_geo_code`, a.timezone as `timezone`, a.name as `name`, a.master_id as `master_id`, a_to_civicrm_value_extra_informatie_3.geldig_adres_12 as `custom_12` FROM civicrm_address a LEFT JOIN `civicrm_value_extra_informatie_3` `a_to_civicrm_value_extra_informatie_3` ON `a_to_civicrm_value_extra_informatie_3`.entity_id = `a`.id WHERE ( `a`.`contact_id` IN (SELECT `id` FROM `civicrm_contact` WHERE is_deleted != 1)) AND (`a`.`id` = "408083") LIMIT 25 OFFSET 0 ;
The part
`a`.`contact_id` IN (SELECT `id` FROM `civicrm_contact` WHERE is_deleted != 1))
will cause the result to be empty, because a.contact_id is NULL.