[SalesForce] No such column ‘ActivitySubtype’ on sobject of type Task

I am new to salesforce development, I am trying to get the user information on entering the phone number from my contacts which is successfully done.
I want to create a call log on getting the user information such as in below image. The task is generated when I omit the CallType and ActivityType fields but the log is created under 'Activity Timeline' tab

enter image description here

My code is as following

$url = "$instance_url/services/data/v20.0/sobjects/Task";

  $content = json_encode(array(
    "Subject"=>'Call',
    "WhoId"=>$name,
    "Status"=> 'not started', // or 'Completed',
    "Description"=>'Description it is',
    "Priority"=>'Normal',
    "CallType "=>'Outbound',
    "ActivityType"=>'Call',
    "ActivitySubtype"=>'Call'

  ));


$curl = curl_init($url);

  curl_setopt($curl, CURLOPT_HEADER, false);

  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

  curl_setopt($curl, CURLOPT_HTTPHEADER,

   array("Authorization: OAuth $access_token",

     "Content-type: application/json"));

  curl_setopt($curl, CURLOPT_POST, true);

  curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

  $json_response = curl_exec($curl);

  $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

  if ( $status != 201 ) {

   die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));

 }

I am getting this error

Error: call to URL https://ap5.salesforce.com/services/data/v20.0/sobjects/Task failed with status 400, response [{"message":"No such column 'ActivitySubtype' on sobject of type Task","errorCode":"INVALID_FIELD"}], curl_error , curl_errno 0

enter image description here

i have looked up into this link for reference

link

Please help me with this.

Best Answer

I think you are using long old version 20.0.

Prefer to use latest version like this:

https://ap5.salesforce.com/services/data/v42.0/sobjects/Task

You should get desired result.

Related Topic