【发布时间】:2020-05-23 09:55:23
【问题描述】:
我正在尝试验证,我的请求结果返回错误。
请求模型
方法:发布,端点:/api/authenticate,标头变量: [{"key":"Content-Type","value":"application/json","enabled":true}], 正文参数:用户名:字符串,密码:字符串, 身份验证类型:字符串
样品申请
POST /api/authenticate
Host: mpop-sit.hepsiburada.com
Content-Type: application/json
{
"username": "xyz_dev",
"password": "XYZ_dev123!",
"authenticationType": "INTEGRATOR"
}
我发送的请求
$url = 'https://mpop-sit.hepsiburada.com//api/authenticate';
$ch = curl_init($url);
$header = array(
'Content-Type: application/json',
'Authorization: Bearer '. base64_encode('xyz_dev:XYZ_dev123!:INTEGRATOR'),
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
$return=json_decode($result,true);
print_r($return);
这是返回的查询结果和我收到的错误。 你认为我可能在哪里犯了错误?
数组([时间戳] => 2020-02-07T09:01:47.426+0000 [状态] => 500 [错误] => 内部服务器错误 [异常] => io.jsonwebtoken.MalformedJwtException [message] => JWT 字符串必须 正好包含 2 个句点字符。找到:0 [路径] => //api/认证)
【问题讨论】:
-
不,我检查了但我没有得到任何结果
-
将网址更改为
https://mpop-sit.hepsiburada.com/api/authenticate或https://mpop-sit.hepsiburada.com/api/authenticate/ -
谢谢,但我得到了同样的错误:(
-
@Mahlika 将此添加到代码末尾
echo curl_error($ch); curl_close($ch);第一个会给您正确的错误,第二个将关闭 curl 连接。我在上面的评论中使用您的代码和第二个网址在本地主机上收到 SSL 证书问题:无法获取本地颁发者证书。这是正确的网址:https://mpop-sit.hepsiburada.com/api/authenticate/我认为,请参阅此帖子以获取 ssl stackoverflow.com/a/59919558/12232340