接收JSON有效负载asp.net

时间:2013-01-16 15:29:46

标签: asp.net .net json

我正在使用API​​发送短信,而以下网址发送短信:

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是一个可选参数,用于告知SMSified您希望发送邮件的发送报告的位置。它必须是SMSified可以通过HTTP发送JSON有效负载的公开URL。

如何使用我的asp.net应用程序接收此JSON有效负载?

以下是发送到定义的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"
  }
}
}

2 个答案:

答案 0 :(得分:1)

这将作为POST HTTP请求进入您的服务器,因此您需要类似于表单处理的asp.net代码。然后使用类似JSON.NET的东西来解析数据。

P.S。不是.net开发人员,但它在各种语言中几乎都是一样的。

答案 1 :(得分:0)

您是否在询问如何编写您的方法?最简单的方法是使用预期的字段/属性创建数据协定。

例如,这里我们有一个UserItem数据契约,并在调用此方法时填充。

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