Laravel guzzle http client POST request example

Laravel guzzle http client POST request example

In this post we will give you information about Laravel guzzle http client POST request example. Hear we will give you detail about Laravel guzzle http client POST request exampleAnd how to use it also give you demo for it if it is necessary.

A very few days ago i was working on my laravel 5.3 application and i require to use WordPress API. I was thinking how to use WP API, But i found docs for WordPress API, But i don’t know how to fire GET, POST, PUT and DELETE request from Laravel side. I did search lot but nothing to find good.

However, I found guzzlehttp package for laravel and little bit read about that, i understand we can simply fire get, post, delete etc request from laravel using guzzlehttp client through. But i was also one query how to make basic auto with POST request but here also solution for this.

So in this post, we learn how to make post request from laravel using http guzzle client. In this example i also added basic authentication for example. It is pretty simple, after this example you can simply use other Website APIs too.

So, For GuzzleHttp, we require “guzzlehttp/guzzle” composer package on our laravel application, Let’s install this package by using following command:

Install guzzlehttp/guzzle package

composer require guzzlehttp/guzzle:~5.0

Ok, now we are ready to use “GuzzleHttpClient” Class on Laravel application, So in route file we can make simple POST request like this way, It is for your understanding, you can call your api instead of “”, Let’s see:

Add In Your Route File

Also see:Laravel 5.7 Guzzle http client POST request example

Route::get('guzzle-http-post-request', function()


$body['title'] = "Body Title";

$body['content'] = "Body Description";

$client = new GuzzleHttpClient();

$url = "";

$response = $client->createRequest("POST", $url, ['auth' => ['root','root'],'body'=>$body]);

$response = $client->send($response);



You simple run GET, PUT and DELETE request like this way.

I hope it can help you…

Hope this code and post will helped you for implement Laravel guzzle http client POST request example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

4  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US