Bayaz
Bayaz

Reputation: 45

Laravel Send Request to endpoint

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();
      }

Upvotes: 1

Views: 1044

Answers (1)

Wael Khalifa
Wael Khalifa

Reputation: 935

You can use Http::post();

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

Upvotes: 1

Related Questions