为什么不支持给定的Grant_Type,为什么我会得到此FedEx API错误。请修改您的请求,然后重试'

发布于 2025-01-26 09:28:26 字数 1003 浏览 2 评论 0原文

我正在使用此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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆凄美了谁 2025-02-02 09:28:26

与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 of x-www-form-urlencoded). Make sure to set your content-type header to application/x-www-form-urlencoded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文