Reputation: 2153
I've setup an asp.net MVC web application to capture post request. I've set breakpoints to see what info is coming through. When an interactive button is clicked, my breakpoint is hit but the object has no details. It simply says {Object} when i hover over value
. When I use Postman and send a raw JSON body, it displays the JSON. May I ask how am i suppose to process the slack object that is sent?
public void Post(object value)
{
// breakpoint here
}
Upvotes: 1
Views: 1119
Reputation: 32698
For interactive messages Slack send a standard POST request with a single form-data encoded parameter called payload
in the body. This parameter contains the data of the actual request as JSON string.
You can simulate this with Postman by using the following parameters:
Content-Type: application/x-www-form-urlencoded
form-data
, with key
=payload
and value
= JSON string.So the body is not fully JSON as you assumed, but contains a form parameter with a JSON encoded string. If you change your app accordingly, it will work.
In c# you can access the content of the payload
parameter with Request["payload"]
(see this answer or details).
Then you still need to decode the JSON string into an object of course. An easy approach is to use JavaScriptSerializer.Deserialize
. (see this answer for details and alternative approaches).
Upvotes: 3