Skip to content
Snippets Groups Projects
Commit dc837d0b authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub
Browse files

Merge pull request #5743 from RocketChat/fix/api-json-parse-error

Return correct error when parsing json on api
parents ddfd7574 44b4ea7e
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,18 @@ Api = new Restivus ...@@ -54,7 +54,18 @@ Api = new Restivus
payloadIsWrapped = @bodyParams?.payload? and payloadKeys.length == 1 payloadIsWrapped = @bodyParams?.payload? and payloadKeys.length == 1
if payloadIsWrapped and @request.headers['content-type'] is 'application/x-www-form-urlencoded' if payloadIsWrapped and @request.headers['content-type'] is 'application/x-www-form-urlencoded'
@bodyParams = JSON.parse @bodyParams.payload try
@bodyParams = JSON.parse @bodyParams.payload
catch e
return {
error: {
statusCode: 400
body: {
success: false
error: e.message
}
}
}
@integration = RocketChat.models.Integrations.findOne @integration = RocketChat.models.Integrations.findOne
_id: @request.params.integrationId _id: @request.params.integrationId
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment