为什么不支持给定的Grant_Type,为什么我会得到此FedEx API错误。请修改您的请求,然后重试'
我正在使用此php代码:
$service_url = 'https://apis-sandbox.fedex.com/oauth/token';
$curl = curl_init($service_url);
$curl_post_data = array(
"content-type" => 'application/json',
"grant_type" => 'client_credentials',
"client_id" => '<client_id>',
"client_secret" => '<client_secret>',
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);
echo $curl_response;
并得到此响应:
{"transactionId": "e147dc65-b09c-4586-be2d-4da3beafa8ed","errors":[{"code":"BAD.REQUEST.ERROR","message":"The given grant_type is not supported. Please modify your request and try again."}]}%
我有service_url,client_id和client_secret,就像它们在FedEx开发人员网站中一样。我不确定问题在哪里。
I'm using this PHP code:
$service_url = 'https://apis-sandbox.fedex.com/oauth/token';
$curl = curl_init($service_url);
$curl_post_data = array(
"content-type" => 'application/json',
"grant_type" => 'client_credentials',
"client_id" => '<client_id>',
"client_secret" => '<client_secret>',
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);
echo $curl_response;
And getting this response:
{"transactionId": "e147dc65-b09c-4586-be2d-4da3beafa8ed","errors":[{"code":"BAD.REQUEST.ERROR","message":"The given grant_type is not supported. Please modify your request and try again."}]}%
I have the service_url, client_id, and client_secret as they are in the FedEx developer site. I'm not sure where the issue is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与Postman一起工作时,我有类似的错误,因为我使用了错误的内容类型(
form-data
而不是x-www-form-urlencoded
)。确保将您的内容类型标头设置为application/x-www-form-urlencoded
。I got a similar error when working with Postman because I was using the wrong content-type (
form-data
instead ofx-www-form-urlencoded
). Make sure to set your content-type header toapplication/x-www-form-urlencoded
.