Overriding HTTP Services API

Last updated on
6 July 2018

If you have the need to override some of the properties defined within your HTTP Service API (let's imagine the REST Services we are going to query are still under development so we have to use a mocked service available at another address), you can do it by using the settings.php file as shown in the HELP fieldset within the HTTP Client Manager settings form.

You don't have to override everything if you don't need it of course.
It's a good practice altering the title property by adding a suffix in order to highlight the fact our HTTP Services API have been overwritten.

There are three types of overriding:

  1. Complete (all of them)
  2. Blacklist (not them)
  3. Whitelist (just them)

Complete override (all of them)

It happens when you need to override the base_uri used by all of your Requests.
You can do it by adding this setting inside your settings.php file:

$settings['http_services_api']['acme_services.contents'] = [
  'title' => '[ACME] - Contents Services API (Mocked)',
  'config' => [
    'base_uri' => 'https://something-1234-acme.my-mock.com',
  ],
];

Blacklist override (not them)

It happens when you need to override the base_uri used by all of your Requests but those in the blacklist which will keep using the default one.
You can do it by adding this setting inside your settings.php file:

$settings['http_services_api']['acme_services.contents'] = [
  'title' => '[ACME] - Contents Services API (Mocked)',
  'config' => [
    'base_uri' => 'https://something-1234-acme.my-mock.com',
  ],
  'commands' => [
    'blacklist' => [
      'GetPostComments',
    ],
  ],
];

Whitelist override (just them)

It happens when you need to override the base_uri used by none of your Requests but those in the whitelist.
You can do it by adding this setting inside your settings.php file:

$settings['http_services_api']['acme_services.contents'] = [
  'title' => '[ACME] - Contents Services API (Mocked)',
  'config' => [
    'base_uri' => 'https://something-1234-acme.my-mock.com',
  ],
  'commands' => [
    'whitelist' => [
      'GetPosts',
    ],
  ],
];

Help improve this page

Page status: No known problems

You can: