how do I call a rest server? I have a Drupal 8 site with a form that I have to submit to another server using the REST protocol.

I have the following information.


server address
server port
form data


I want to submit that information to the other server.

Is there any function I can use in Drupal 8?
Because of the new Proudly Found Elsewhere standard, Drupal doesn't have its own client.

It does however include Guzzle, a well respected library. You can use that to make your REST calls, or of course include and use another library if you wish.

You can get to the Guzzle client in a default Drupal 8 install through the http_client service:

$httpClient = \Drupal::httpClient();


And the docs for Guzzle are here.