I'm trying to make a post
http request using Illuminate\Support\Facades\Http
.
My request :
$response = Http::post(
$this->api.'/auth',
[
'auth' => [
'username' => $this->username,
'password' => $this->password
]
]
)->json('response');
While api
,username
and password
are set in a __construct
method.
This request is working well in postman. But when I run it on php server I get a null
.
I digged in the response and I found the following :
Illuminate\Http\Client\Response {#2741 ▼
#response: GuzzleHttp\Psr7\Response {#2766 ▼
-reasonPhrase: "Not Acceptable"
-statusCode: 406
-headers: array:5 [▼
"Server" => array:1 [▶]
"Date" => array:1 [▶]
"Content-Type" => array:1 [▶]
"Content-Length" => array:1 [▶]
"Connection" => array:1 [▶]
]
-headerNames: array:5 [▼
"server" => "Server"
"date" => "Date"
"content-type" => "Content-Type"
"content-length" => "Content-Length"
"connection" => "Connection"
]
-protocol: "1.1"
-stream: GuzzleHttp\Psr7\Stream {#2765 ▼
-stream: stream resource @28 ▶}
-size: null
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}
}
Do you have an idea on how to solve this ?