SmartThings - The request is malformed

I’m trying to set up the SmartThings integration. When I go to enter my access token, I receive the error:

“SmartThings could not validate the webhook URL. Please ensure the webhook URL is reachable from the internet and try again.”

Thing is, I’m using Nabu Casa. So I’m pretty sure the webhook URL is right. This is confirmed by the fact that I get an exception in my HA log whenever I try to submit the access token.

Here is the exception I see:

2020-06-15 15:41:51 ERROR (MainThread) [homeassistant.components.smartthings.config_flow] API error setting up the SmartApp: {'requestId': 'A64E301C-FA3C-44B3-9BC2-F118FAE017DD', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetNon200Error', 'target': 'https://hooks.nabu.casa/XXX_I_removed_this_since_it_may_be_sensitive_XXX', 'message': 'Target did not respond with a 200 status. Upstream status code=404', 'details': []}]}}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 108, in async_step_pat
    await update_app(self.hass, app)
  File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 174, in update_app
    await app.save()
  File "/usr/local/lib/python3.7/site-packages/pysmartthings/app.py", line 349, in save
    response = await self._api.update_app(self._app_id, self.to_data())
  File "/usr/local/lib/python3.7/site-packages/pysmartthings/api.py", line 179, in update_app
    return await self.put(API_APP.format(app_id=app_id), data)
  File "/usr/local/lib/python3.7/site-packages/pysmartthings/api.py", line 399, in put
    return await self.request("put", self._api_base + resource, data=data)
  File "/usr/local/lib/python3.7/site-packages/pysmartthings/api.py", line 374, in request
    data=data,
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "A64E301C-FA3C-44B3-9BC2-F118FAE017DD", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetNon200Error", "target": "https://hooks.nabu.casa/XXX_I_removed_this_since_it_may_be_sensitive_XXX", "message": "Target did not respond with a 200 status. Upstream status code=404", "details": []}]}}

I’m running HA 111.1. Anyone have any ideas what may be going on?

Any ideas? I’ve been stuck here for a few days now.

In the conifg/.storage directory there is a file called smartthings. I renamed this file, rebooted HA, then tried to re-add the SmartThings integration. This generated a new Nabu Casa URL, and I was able to successfully add the integration.

Not sure what happened with the original, but blowing that file away and starting over resolved my issue.

Didn’t work for me. new install, well I’m trying to install.

There does not appear that anyone is following this post and I’ve seen no fix anywhere. Even the post found do not seem to have a clear answer and I’ve tried them all with no success hoping someone can assist here. Thanks

2021-04-18 06:08:36 ERROR (MainThread) [homeassistant.components.smartthings.config_flow] API error setting up the SmartApp: {‘requestId’: ‘80526DD3-C49D-46CB-93EE-78AF2821FEEB’, ‘error’: {‘code’: ‘ConstraintViolationError’, ‘message’: ‘The request is malformed.’, ‘details’: [{‘code’: ‘TargetNon200Error’, ‘target’: ‘https://xxx.xxxxxxxx.com/api/webhook/2a1f2b305ff092e762c7ffc6b2472cf2ac52b5be150fd3c7d96a6ac9193a0cc2’, ‘message’: ‘Target did not respond with a 200 status. Upstream status code=403’, ‘details’: []}]}}
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py”, line 130, in async_step_pat
app, client = await create_app(self.hass, self.api)
File “/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py”, line 145, in create_app
app, client = await api.create_app(app)
File “/usr/local/lib/python3.8/site-packages/pysmartthings/smartthings.py”, line 110, in create_app
entity = await self._service.create_app(app.to_data())
File “/usr/local/lib/python3.8/site-packages/pysmartthings/api.py”, line 171, in create_app
return await self.post(API_APPS, data)
File “/usr/local/lib/python3.8/site-packages/pysmartthings/api.py”, line 395, in post
return await self.request(“post”, self._api_base + resource, data=data)
File “/usr/local/lib/python3.8/site-packages/pysmartthings/api.py”, line 368, in request
raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {“requestId”: “80526DD3-C49D-46CB-93EE-78AF2821FEEB”, “error”: {“code”: “ConstraintViolationError”, “message”: “The request is malformed.”, “details”: [{“code”: “TargetNon200Error”, “target”: “https://xxx.xxxxxxxx…com/api/webhook/2a1f2b305ff092e762c7ffc6b2472cf2ac52b5be150fd3c7d96a6ac9193a0cc2”, “message”: “Target did not respond with a 200 status. Upstream status code=403”, “details”: []}]}}

Thanks. That worked for me. I spent hours figuring this out

1 Like

I’m having this very same problem, did you find a solution?

no very frustrating.

It might be the TLS config. Check this post.

Check your ip_bans.yaml! Try removing anything in that file and restart Home Assistant before trying to add the integration.

Somehow the smartthings servers got banned in my case and that led to the error message with upstream status code=403 showing up.

Took me ages to find that out.