user2067789
user2067789

Reputation: 11

cURL: HTTP method GET is not supported by this URL, Error 405

I am trying to do a cURL query to a google server directly from the command line (on windows 7). The server belongs to google's speech api and does speech recognition. Therefore it needs an upload of a audio file, and gives back the recognition result. So I connect two cURL queries, one uploading, one downloading. Like that:

curl "https://..." & curl "https://..."

I get back the following error:

<HTML>
<HEAD>
<TITLE>HTTP method GET is not supported by this URL</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>HTTP method GET is not supported by this URL</H1>
<H2>Error 405</H2>
</BODY>
</HTML>
{"result":[]}

Since I do not directly use the GET method I can't change anything. Please help.

Thanks!


Edit:

The URLs (with x, y and z for keys etc.):

curl "https://www.google.com/speech-api/full-duplex/v1/down?pair=xxxxxx" & curl "https://www.google.com/speech-api/full-duplex/v1/up?lang=de-DE&lm=dictation&client=yyyy&pair=xxxxxx&key=zzzzzzz" --header "Content-Type: audio/amr; rate=16000" --data-binary @test.amr

Upvotes: 1

Views: 7101

Answers (2)

Robert Rowntree
Robert Rowntree

Reputation: 6289

AMR-NB with a sample rate of 8000 should work. I tried amr-wb and it failed.

longer sample curl with log=V

rob@ beacon$ curl "https://www.google.com/speech-api/full-duplex/v1/down?pair=12345678901234567" & curl -X POST "https://www.google.com/speech-api/full-duplex/v1/up?lang=en-US&lm=dictation&client=chromium&pair=12345678901234567&key=.....PMU" --header "Transfer-Encoding: chunked" --header "Content-Type: audio/x-flac; rate=22050"  --data-binary @11.rec
[1] 16320

{"result":[]}
rob@ beacon$ {"result":[{"alternative":[{"transcript":"hi how are you we have to go down to the store and see if we can get the groceries for this week so we can bring them back in the car","confidence":0.971865}],"final":true}],"result_index":0}

two curl expressions connected by & within a couple seconds, you see the result. Note one GET, one POST and note the headers on the POST.

Upvotes: 2

Tim
Tim

Reputation: 1433

curl by default uses the GET method. You need to use it with -X POST so it uses POST. And second, you want to upload a file, so you need to add that as a parameter, too: -d @filename.

Read more about curl on the man page.

Upvotes: 0

Related Questions