title: Error 500 internal server error when sending post http request using Guzzle
body: <p>I am trying to send an post http request using Guzzle but i got error 500 </p>
  
  <pre><code>Internal server error 
  ServerException in RequestException.php line 113:
  Server error: `POST https://domainname/api/v1/user/register` resulted in a `500 Internal Server Error` response:
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8" /&gt;
  &lt;meta name="robots" content="noindex,nofo (truncated...)
  </code></pre>
  
  <p>I tried to send the same header and body keys using Postman , it worked without any issue :</p>
  
  <pre><code>{
      "status": "true"
  }
  </code></pre>
  
  <p>Header:
  <a href="https://i.stack.imgur.com/Mc24f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mc24f.png" alt="enter image description here"></a>
  Body:
  <a href="https://i.stack.imgur.com/94hmt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/94hmt.png" alt="enter image description here"></a></p>
  
  <p>This is my Guzzle client request :-</p>
  
  <pre><code>        $client = new GuzzleHttp\Client(['base_uri' =&gt; 'https://domainname/api/v1/']);
                     $response = $client-&gt;request('POST', 'user/register', [
                         'headers' =&gt; [
                             'Authorization' =&gt; Session::get('token'),
                             'Content-Type'     =&gt; 'application/x-www-form-urlencoded',
                         ],
                         'form_params' =&gt; [
                             'start_date' =&gt; $start_date,
                             'expiry_date' =&gt; $expiry_date,
                             'type' =&gt; 'normal',
                             'status' =&gt; 'active',
  
                         ]
                     ]);
  
                      $response= $response-&gt;getBody();
                      $re= json_decode($response);
  </code></pre>
  
  <p>My route to that api:-</p>
  
  <pre><code>Route::post('/user/register', 'UsersAPI@register'); 
  </code></pre>
  
  <p>My Register controller :</p>
  
  <pre><code>public function register(Request $request){
  Log::info('Request: ' . $request);
  //dd($request-&gt;all());
       $validator = Validator::make($request-&gt;all(), [
          // 'user_id' =&gt; 'required',
          'start_date' =&gt; 'required',
          'expiry_date' =&gt; 'required',
          'type' =&gt; 'required',
          'status'=&gt;'required',   
          //'receipt' =&gt; 'required',
          //'purchase_id'=&gt;'required',
      ]);
  
      $user = JWTAuth::toUser(); 
        //Check whether validation is failed or passed
      if($validator-&gt;fails()){
          //Redirect back with validation errors
          return response()-&gt;json(['error' =&gt; $validator-&gt;errors()], 400);
      }
  
  
  
           $user = new User($data);
          $user-&gt;user()-&gt;save($user);
       Log::info('save_user done for this user: ' . $user-&gt;id);
  
  
      return ['status' =&gt; 'true']; 
  }
  </code></pre>
  
  <p>NGINX error.log :-</p>
  
  <pre><code>[02/Dec/2017:15:49:13 +0300] "POST /api/v1/user/register HTTP/1.1" 500 16904 "-" "GuzzleHttp/6.2.1 curl/7.55.0 PHP/7.1.9"
  </code></pre>