Fix 500 error if request body is not JSON object

In `JsonBodyMiddleware` we expect POST body to be a JSON dictionary,
and failed with 500 error if body was a valid JSON, but not a
dictionary.  Additional check was added along with a test for described
case.

Change-Id: I08ae3c8fa4eb53b67604d8b8791ca19d9c1682e6
Closes-Bug: #1316657
Merge "Fix 500 error if request body is not JSON object"