Alexa API endpoint method not allowed

I am now also having a similiar issue. Amazon’s Service Simulator will not hit my endpoint. It simply states:

There was an error calling the remote endpoint, which returned HTTP 404 : Not Found

However, if I take the same URL, put it in Postman, POST to the URL with the same Service Request JSON, I get a good 200 response back.

I have a valid, signed SSL certificate in place and am going straight over 443. I don’t know what else to try since I cannot get any more details about the request Amazon is trying to make.

I’m also getting a Python error.

In the Amazon dev console, the Service Simulator is the first indicator of a problem.

In “Enter utterance” to test, I put in:

activate typical night

The Service Request spits out:

{
  "session": {
    "sessionId": "SessionId.32e606f1-6dcd-4553-81c4-33c3a3bc1ba4",
    "application": {
      "applicationId": "amzn1.ask.skill.454352a3-9a05-4e54-8182-6287d5364b90"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.AHKWH7632FVDHHSXT343NQ7XKPZJEK4KLX35YRJN2SO46ZJ5HMXB27OM7FFKGCSRCET2QTW5QTNJTN2G43N575Z3OYSGE32POXQQPSQFDGCKULDCVUX5O3FSU6R6HV55NLIELDKFKJZRBN64RP6ZXIFX7Z2HUSGJ5XUD4IAZLDYEIFN5QXYWYHG33JE65CJTHNLD4M626WJTW6A"
    },
    "new": true
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.4b5b1aef-cb65-4619-8440-99104e5be205",
    "locale": "en-US",
    "timestamp": "2016-12-30T07:00:49Z",
    "intent": {
      "name": "ActivateSceneIntent",
      "slots": {
        "Scene": {
          "name": "Scene",
          "value": "typical sleep"
        }
      }
    }
  },
  "version": "1.0"
} 

The Service Response says:

The remote endpoint could not be called, or the response it returned was invalid.

So I poked at it with curl:

curl -k -X POST https://REDACTED.dyndns.org/api/alexa?api_password=REDACTED

Interestingly, this gets a 500 error.

Server got itself in trouble

When this happens, the logs report a python error:

INFO:homeassistant.components.http:Serving /api/alexa to 50.46.133.153 (auth: True)
ERROR:aiohttp.web:Error handling request
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/aiohttp/server.py", line 261, in start
yield from self.handle_request(message, payload)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/aiohttp/web.py", line 88, in handle_request
resp = yield from handler(request)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http.py", line 508, in handle
result = yield from result
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/alexa.py", line 136, in post
data = yield from request.json()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/aiohttp/web_reqrep.py", line 321, in json
return loads(body)
File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

Now, the non-API URLS work. The web interface works just fine. https://REDACTED.dyndns.org, which I believe proves that my router port forwarding is set up correctly.

I’ll take a closer look at the source code later to see why it’s dying there.

Just an update that I fixed my problem. It was an issue with the SSL. Turns out that Amazon really wants you to use the configuration file method they detail at https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/testing-an-alexa-skill#create-a-private-key-and-self-signed-certificate-for-testing

He Guys,

if anyone get stuck with this error also. For me it was my API-Password. I had an # in my Password. This was my error, not the Lets encrypt Cert. If set an Password with only numbers and letters. Now it is working.

Hi guys,
I also had this “500 - Internal server error” issue… It has been caused by a wrong Intent configuration/wrong indent format of my configuration.yml -alexa-section.
Just make sure to use some very, very simple intent config during setup phase like:

alexa:
  intents:
    SpeakIntent:
      speech:
        type: plaintext
        text: This is magic 

This worked out finally… besides the 443-port issue, the exact (sub)domain name in the certificate and so on…

Cheers,
Bastian

I have the same “internal server error”.

This is my config:

alexa:
  intents:
    WhereAreWeIntent:
      speech:
        type: plaintext
        text: Lorem ipsum

Port 443 is redirected, and I can use iftt without any problems.

When I create a post request to https://redacted.com/api/alexa?api_password=redacted in the home-assistant.log the following error appears:

17-03-06 20:37:49 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_server.py", line 62, in handle_request
    resp = yield from self._handler(request)
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web.py", line 270, in _handle
    resp = yield from handler(request)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 57, in ban_middleware_handler
    return (yield from handler(request))
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 417, in handle
    result = yield from result
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/alexa.py", line 136, in post
    data = yield from request.json()
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_reqrep.py", line 405, in json
    return loads(body)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

Any ideas?

Could you solve the problem?

Nope… and I haven’t tried since then.

I still have the 500-Error but the Alexa-Skill works right now.