【问题标题】:Receiving JSON payload asp.net接收 JSON 有效负载 asp.net
【发布时间】:2013-01-16 15:29:46
【问题描述】:

我正在使用 API 发送短信,下面的 URL 发送短信:

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"
  }
}
}

【问题讨论】:

    标签: asp.net .net json


    【解决方案1】:

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

    附言不是 .net 开发人员,但每种语言都差不多。

    【讨论】:

      【解决方案2】:

      你是在问你的方法应该怎么写?最简单的方法是创建具有预期字段/属性的数据合同。

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-02-20
        • 1970-01-01
        • 2020-12-01
        • 2013-04-12
        • 2019-12-13
        • 1970-01-01
        • 2013-08-04
        • 1970-01-01
        相关资源
        最近更新 更多