0

I need to use the Google Translate API in my Laravel application, get requests are working fine, but post requests don't seem to, I tried with Postman and got the same error message.

Here's the test I made:

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",
    ]);
});

Here's the test with Postman: enter image description here

enter image description here

Here's the error I got in both tests:

enter image description here

I don't know what went wrong, any suggestions?

1 Answers1

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

Pratham
  • 497
  • 3
  • 7