You are here

public function RestClient::objectCreate in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objectCreate()
  2. 5.0.x src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objectCreate()

Create a new object of the given type.

Parameters

string $name: Object type name, E.g., Contact, Account, etc.

array $params: Values of the fields to set for the object.

Return value

\Drupal\salesforce\SFID The new object's SFID.

Overrides RestClientInterface::objectCreate

1 method overrides RestClient::objectCreate()
TestRestClient::objectCreate in src/Tests/TestRestClient.php
Create a new object of the given type.

File

src/Rest/RestClient.php, line 496

Class

RestClient
Objects, properties, and methods to communicate with the Salesforce REST API.

Namespace

Drupal\salesforce\Rest

Code

public function objectCreate($name, array $params) {
  $response = $this
    ->apiCall("sobjects/{$name}", $params, 'POST', TRUE);
  $data = $response->data;
  return new SFID($data['id']);
}