You are here

public function RestClient::httpRequestRaw in Salesforce Suite 5.0.x

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

Return raw response content from given URL.

Useful for fetching data from binary fields like Attachments.

Parameters

string $url: The url to request.

Return value

mixed The raw http response body.

Throws

\Exception

Overrides RestClientInterface::httpRequestRaw

File

src/Rest/RestClient.php, line 276

Class

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

Namespace

Drupal\salesforce\Rest

Code

public function httpRequestRaw($url) {
  if (!$this->authManager
    ->getToken()) {
    throw new \Exception($this
      ->t('Missing OAuth Token'));
  }
  $headers = [
    'Authorization' => 'OAuth ' . $this->authToken
      ->getAccessToken(),
    'Content-type' => 'application/json',
  ];
  $response = $this
    ->httpRequest($url, NULL, $headers);
  return $response
    ->getBody()
    ->getContents();
}