Answers.Body: <p>Turns out there is a bug in the CiviMobile extension that is breaking this functionality. Disabling this extension fixes the problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-18T11:54:35.870Z
Answers.LastActivityDate: 2020-02-18T11:54:35.870Z
Answers.UserDisplayName: Tony Horrocks
Answers.Body: <p>There is an extension for a case activity API, although I have not tested it for a while! <a href="https://civicrm.org/extensions/caseactivity-api" rel="nofollow noreferrer">https://civicrm.org/extensions/caseactivity-api</a>
  That might help you?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T13:26:55.960Z
Answers.LastActivityDate: 2020-02-05T13:26:55.960Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>Parameter <code>contact_id</code> should be <code>target_contact_id</code> (if looking for client) or <code>source_contact_id</code> (if looking for author).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T15:12:02.897Z
Answers.Text: There is a catchall for any activity contact in the API called contact_id...but I tried your suggestion as well - same error.
Answers.UserDisplayName: Tony Horrocks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T15:14:31.593Z
Answers.Text: Oh ok. Is there a stack trace in ConfigAndLog? I don't get an error.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T16:07:59.977Z
Answers.Text: I wish. Nothing. Are you using PHP to test or are you using the API explorer?
Answers.UserDisplayName: Tony Horrocks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T16:17:27.003Z
Answers.Text: I used `cv php:eval`. Actually if you're catching the exception yourself then there won't be a stacktrace in the log. You can either put debug_backtrace() in your error handler, or let civi log the error instead (don't catch the error).
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-06T10:06:39.783Z
Answers.Text: OK on this I used a Drupal view to get the ID of the activity I wanted. I put this into a Drupal rule to load the activity entity by activity ID - and it will not load it there either. Im just wondering if when it is part of a case, there is a permissions issue with it?
Answers.UserDisplayName: Tony Horrocks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-06T10:18:27.163Z
Answers.Text: I also just tried using the APIto do the same thing and it returns the error even if you use the activity ID.
Answers.UserDisplayName: Tony Horrocks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-06T10:39:47.967Z
Answers.Text: Actually I just tried it as user 1 and there was no error so it must be permissions.
Answers.UserDisplayName: Tony Horrocks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-05T13:38:07.113Z
Answers.LastActivityDate: 2020-02-05T13:38:07.113Z
Answers.UserDisplayName: Demerit
Body: <p>Im using API3 to get activities</p>
  
  <p>My code is</p>
  
  <pre><code>function hook_any_activity_get($cid,$type) {
    $params = [
      'contact_id' =&gt; $cid,
      'activity_type_id' =&gt; $type,
      'sequential' =&gt; 1,
      'is_deleted' =&gt; 0,
    ];
    try{
      $result = civicrm_api3('Activity', 'get', $params);
    }
    catch (CiviCRM_API3_Exception $e) {
      // Handle error here.
      $errorMessage = $e-&gt;getMessage();
      $errorCode = $e-&gt;getErrorCode();
      $errorData = $e-&gt;getExtraParams();
      return [
        'is_error' =&gt; 1,
        'error_message' =&gt; $errorMessage,
        'error_code' =&gt; $errorCode,
        'error_data' =&gt; $errorData,
      ];
    }
    return $result;
  }
  </code></pre>
  
  <p>This works fine when the activity is created outside of a case.</p>
  
  <p>When the activity is created within a case I get an error</p>
  
  <p>One of parameters  (value: ) is not of the type Positive</p>
  
  <p>I have tried this written into a module and in Drupal rules. Same error.</p>
  
  <p>I'm not seeing anything in backtrace or the CiviCRM log file.</p>
  
  <p>Ive even tried it just by trying to return the activity using the activity ID.</p>
  
  <p>I also tried it by including the case ID</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-05T11:52:36.463Z
Comments.Text: Are you on the latest civicrm version?
Comments.UserDisplayName: jitendra - fuzion
Tags: <api><civicase><activity>
Title: Activity get API3 does not return case activity
ThreadText: # Activity get API3 does not return case activity
  
  (Asked by: username_0 on 2020-02-05)
  
  Im using API3 to get activities
  
  My code is
  
  ```
  function hook_any_activity_get($cid,$type) {
    $params = [
      'contact_id' => $cid,
      'activity_type_id' => $type,
      'sequential' => 1,
      'is_deleted' => 0,
    ];
    try{
      $result = civicrm_api3('Activity', 'get', $params);
    }
    catch (CiviCRM_API3_Exception $e) {
      // Handle error here.
      $errorMessage = $e->getMessage();
      $errorCode = $e->getErrorCode();
      $errorData = $e->getExtraParams();
      return [
        'is_error' => 1,
        'error_message' => $errorMessage,
        'error_code' => $errorCode,
        'error_data' => $errorData,
      ];
    }
    return $result;
  }
  
  ```
  
  This works fine when the activity is created outside of a case.
  
  When the activity is created within a case I get an error
  
  One of parameters (value: ) is not of the type Positive
  
  I have tried this written into a module and in Drupal rules. Same error.
  
  I'm not seeing anything in backtrace or the CiviCRM log file.
  
  Ive even tried it just by trying to return the activity using the activity ID.
  
  I also tried it by including the case ID
  
  **Tags:** api, civicase, activity
  
  > **Comments:**
  > **username_1**: Are you on the latest civicrm version?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2020-02-18. Score: 2
  
  Turns out there is a bug in the CiviMobile extension that is breaking this functionality. Disabling this extension fixes the problem.
  
  
  ---
  
  ### Answer by username_2 on 2020-02-05. Score: 1
  
  There is an extension for a case activity API, although I have not tested it for a while! <https://civicrm.org/extensions/caseactivity-api>
  That might help you?
  
  
  ---
  
  ### Answer by username_3 on 2020-02-05. Score: 1
  
  Parameter `contact_id` should be `target_contact_id` (if looking for client) or `source_contact_id` (if looking for author).
  
  > **Comments:**
  > **username_0**: There is a catchall for any activity contact in the API called contact_id...but I tried your suggestion as well - same error.  
  > **username_3**: Oh ok. Is there a stack trace in ConfigAndLog? I don't get an error.  
  > **username_0**: I wish. Nothing. Are you using PHP to test or are you using the API explorer?  
  > **username_3**: I used `cv php:eval`. Actually if you're catching the exception yourself then there won't be a stacktrace in the log. You can either put debug_backtrace() in your error handler, or let civi log the error instead (don't catch the error).  
  > **username_0**: OK on this I used a Drupal view to get the ID of the activity I wanted. I put this into a Drupal rule to load the activity entity by activity ID - and it will not load it there either. Im just wondering if when it is part of a case, there is a permissions issue with it?  
  > **username_0**: I also just tried using the APIto do the same thing and it returns the error even if you use the activity ID.  
  > **username_0**: Actually I just tried it as user 1 and there was no error so it must be permissions.  
  
  ---
  
  