0

我需要在我的 Laravel 应用程序中使用 Google Translate API,获取请求工作正常,但发布请求似乎没有,我尝试使用 Postman 并收到相同的错误消息。

这是我做的测试:

Route::get('/', function () {
    return Http::withHeaders([
        "content-type" => "application/x-www-form-urlencoded",
        "accept-encoding"=> "application/gzip",
        "x-rapidapi-key"=> "<rapid_api_key_here>",
        "x-rapidapi-host"=> "google-translate1.p.rapidapi.com",
        "useQueryString"=> true
    ])->post('https://google-translate1.p.rapidapi.com/language/translate/v2/detect', [
        "q"=> "English is hard, but detectably so",
    ]);
});

这是 Postman 的测试: 在此处输入图像描述

在此处输入图像描述

这是我在两个测试中得到的错误:

在此处输入图像描述

不知道哪里出了问题,有什么建议吗?

4

1 回答 1

0

You can try using Route::post method instead of get as you're making a post request here.

Context: https://laravel.com/docs/5.0/routing#basic-routing

于 2021-09-01T10:26:21.560 回答