function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jkropkajkropka 

Creating a case using API

Anone know how to create a case using the API

I have tried both of these methods:

  $fields = array('type' => 'Case',
   'Type'=>"$type",
   'ContactId'=>"$ContactId",
   'Severity' => "$severity",
   'Subject'=>"$subject",
   'Description'=>"$description");
  $case = new SF_Object($client,$fields);
  $case->set_fields($fields);

$ok = $case->add();

and also

$ok = $sfobj->create($case);

Both methods give the result:

 common.exception.ApiException: Must send a concrete entity type.

What am I missing about creating (inserting) new cases?

Ron HessRon Hess
looks like perl, so here goes

$sf = new Salesforce::SforceService->get_port_binding('Soap');
$sf->login( %{user_and_passwd()} );

my $r = $sf->create( type=>'Case',
Subject=>'Request for Account',
Status=>'PSG',
Origin=>'E-mail',
Reason=>'System / User Setup',
Type=>'EDI',
OwnerId=> '00G00000006p7DnEAI', # some Queue
Description=> $body,
);
print "create Account Request case ",Dumper($r->result);


now you may need to tweak your Salesforce.pm , i know mine has a few tweaks from the standard one.

you are using perl , yes?

if so, you don't need an array() construct, but you do need a binding to the port
which is then "logged in"
jkropkajkropka
actually its PHP, but I'll review your reply to see if it sheds any light on my problem.

Thanks.
jkropkajkropka
Here is where I am today (still not working)

$client = new SalesforceClient($SESSION);


$result = $client->create(array('type'=>'Case','ContactId'=>$ContactId,'Severity'=>$severity,'Subject'=>$subject, 'Description'=>$description));


which gives the result:
SOAP_Fault
common.exception.ApiException: Must send a concrete entity type.

I'm beginnin to think there is a problem with the SalesforceClient.php which
is in the developers toolkit from salesforce. I works OK fetching data from
salesforce, but not for create or update.
jkropkajkropka
Just as I suspected the creation problem was being caused by the setup. My
WebService_SforceService_Soap.php was pointing to the SOAP client here:
https://www.salesforce.com/services/Soap/c/6.0

I got it working by pointing to the client here:
https://www.salesforce.com/services/Soap/u/6.0
instead.