user959883
user959883

Reputation:

Receiving JSON payload asp.net

I am using an API to send SMS and below URL sends an SMS:

https://api.smsified.com/v1/smsmessaging/outbound/7243203328/requests?address=1234567890&message=this%20shall%20send%20delivery%20notice&notifyURL=http%3A%2F%2Flocalhost%2FWebsite8%2FDefault.aspx

NotifyURL is an optional parameter that tells SMSified where you want the delivery report for your message to be sent. It needs to be a publicly available URL that SMSified can send a JSON payload to over HTTP.

How can I receive this JSON payload sent using my asp.net application?

Here's an example of the data sent to the defined notifyURL:

{
"deliveryInfoNotification": {
  "deliveryInfo": {
  "address": "14075550100", 
  "code": "0", 
  "createdDateTime": "2011-05-12T00:55:25.313Z", 
  "deliveryStatus": "DeliveredToNetwork", 
  "direction": "outbound", 
  "message": "Hello world", 
  "messageId": "3e5caf2782cb2eb310878b03efec5083", 
  "parts": "1", 
  "senderAddress": "16575550100", 
  "sentDateTime": "2011-05-12T00:55:34.359Z"
  }
}
}

Upvotes: 0

Views: 727

Answers (2)

Jacob Clouse
Jacob Clouse

Reputation: 45

Are you asking how your method should be written? The easiest way is to create a data contract with the expected fields/properties.

For example, here we have a UserItem data contract and that is populated when this method is called.

    [WebInvoke(UriTemplate = "", Method = "POST")]
    public List<UserItem> CreateAccount(UserItem sentUser)
    {
    }

Upvotes: 0

Zepplock
Zepplock

Reputation: 29135

This will come to your server as a POST HTTP request so you need asp.net code similar to that you have for form processing. Then use something like JSON.NET to parse the data.

p.s. not a .net developer but it's pretty much the same in every language.

Upvotes: 1

Related Questions