Reputation: 6094
This is a webhook activity I am trying do using postman. The post content is the below json.
{
"model":{
"id":"560a32d2a1dcb7902a7ad596",
"name":"cool features",
"pos":32767.5
},
"action":{
"id":"567537b94332a7d8489a0d26",
"idMemberCreator":"55024f3fdd60428e915d2c2b",
"data":{
"board":{
"shortLink":"SUDki3AR",
"name":"recipe",
"id":"560a31fad96886a87cabf39a"
},
"list":{
"name":"cool features",
"id":"560a32d2a1dcb7902a7ad596"
},
"card":{
"shortLink":"sufSA867",
"idShort":18,
"name":"added",
"id":"567537b94332a7d8489a0d25"
}
},
"type":"createCard",
"date":"2015-12-19T10:55:53.904Z",
}
}
rails strips away the action key value from params. I can only get it using request.raw_post
. But it is a string . Is there a way to get the action value in the json in params? String manipulation would be very difficult.
Upvotes: 0
Views: 61
Reputation: 8658
Rails sets the params controller
and action
on every request, so it overwrites your action
.
As you already found out, you can get the request string and as you know it's json, you can parse it (by the way: your json is invalid, an extra ,
after date
):
action = JSON.parse(request.raw_post)['action']
Upvotes: 3