I'm attempting to make a curl request to my python api that is using the AWS package Chalice.
When I try to access the app.current_request.json_body
a JSON Parse error is thrown. Cannot figure out why this is happening. My JSON is formatted properly as far as I can tell.
Here is the curl request:
(echo -n '{"data": "test"}') |
curl -H "Content-Type: application/json" -d @- $URL
Here is the python Chalice code:
app = Chalice(app_name='predictor')
@app.route('/', methods=['POST'], content_types=['application/json'])
def index():
try:
body = app.current_request.json_body
except Exception as e:
return {'error': str(e)}
When I invoke the route using the above curl
request I get the following error:
{"error": "BadRequestError: Error Parsing JSON"}
Note: When I remove the .json_body
from the app.current_request
. I no longer get the error.
Any thoughts?