Laravel Send Request to endpoint

1k Views Asked by At

These codes throw "Bad Request" error because of parameter. What is the problem of parameter syntax.

try{         
    $client = new Client();    
    $response = $client->post("url",
    ['s' => $s, 'p'=> $p]);
    
    } catch (ClientException $e) {
        echo $e->getMessage();
    } catch (RequestException $e) {
        echo $e->getMessage();
      }
1

There are 1 best solutions below

2
Wael Khalifa On

You can use Http::post();

use Illuminate\Support\Facades\Http;
$response =  Http::post('http://example.com/users',['your data']);