php - 无法做出 HTTP Post 请求响应:GuzzleHttp\Psr7\Response "Not Acceptable"
问题描述
我正在尝试post
使用Illuminate\Support\Facades\Http
.
我的请求 :
$response = Http::post(
$this->api.'/auth',
[
'auth' => [
'username' => $this->username,
'password' => $this->password
]
]
)->json('response');
While api
, username
andpassword
被设置在一个__construct
方法中。
这个请求在邮递员中运行良好。但是当我在 php 服务器上运行它时,我得到一个null
. 我深入研究了回复,发现以下内容:
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: []
}
}
你知道如何解决这个问题吗?
解决方案
推荐阅读
- java - Java调度线程池执行器内部队列
- c++ - 为什么我们在 C++ 中声明头文件时,空格不被视为空格?
- javascript - 为什么以下 Puppeteer 脚本为 ExecutionContext.evaluateHandle 提供“未定义”?
- ruby-on-rails - 将 Rails 应用程序推送到 Heroku 时出现“预编译资产失败”
- json - 将 JSON 映射到 Apama 事件
- ember.js - Ember:如何通过参数传递多个参数以路由
- javascript - 我可以使用布尔值来解决这个问题吗?
- python - Lambda 事件返回空对象
- mongodb - 使用 min 验证器验证 mongoose 编号字段
- python - python-gdb 错误:Python 异常
类型没有目标