How to add HTTP Headers

Created on 18 July 2019, almost 5 years ago
Updated 21 March 2024, 3 months ago

Hello,

I need to add

CURLOPT_HTTPHEADER => array(
    "x-api-version: 2.0",
    "Authorization: ApiKey key=\"{{api-key}}\""
  )

in my request. How to achieve that in external_entities ?

I tried this but it didn't work :

  /**
   * Gets the HTTP headers to add to a request.
   *
   * @return array
   *   Associative array of headers to add to the request.
   */
  public function getHttpHeaders() {
    $headers = ['x-api-version' => '2.0'];

    if ($this->configuration['api_key']['header_name'] && $this->configuration['api_key']['key']) {
      $headers[$this->configuration['api_key']['header_name']] = $this->configuration['api_key']['key'];
    }

    return $headers;
  }

Thank for your help

πŸ’¬ Support request
Status

Active

Component

Code

Created by

πŸ‡«πŸ‡·France estoclet

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024