What does the following Azure Notification Hub REST response mean: 'The specified resource description is invalid.'?

醉酒当歌 提交于 2019-12-06 16:37:40

Try this:

  1. Call Create Registration ID
  2. Store retrieved id in your DB
  3. Call Create or Update Registration to create registration
  4. Each time you want to update that registration in future (refresh channel, modify tags...) you just call Create or Update Registration again

I've just successfully played with payload bellow:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <title type="text"></title>
  <updated>2014-10-21T23:57:08Z</updated>
  <content type="application/atom+xml;type=entry;charset=utf-8">
    <WindowsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
      <Tags>t1,t2</Tags>
      <ChannelUri>https://db3.notify.windows.com/?token=AwYAAABXiUp%2bD8v1%2bVfWbWLr3FZ3rQcJtPkUgFwaiGZus4GbtkM8zbZ6uQt1NKXpC4FOtYWHDxXvBb3FkoefaozvCYTFiDjhdb3jDuORUDY8zBlkGw1MxY0QjrH7G0fFbW0RXgo%3d</ChannelUri>
      <BodyTemplate><![CDATA[<?xml version="1.0" encoding="utf-16"?><root></root>]]></BodyTemplate>
      <WnsHeaders>
        <WnsHeader>
          <Header>X-WNS-Type</Header>
          <Value>wns/raw</Value>
        </WnsHeader>
      </WnsHeaders>
      <TemplateName>MyTemplate</TemplateName>
    </WindowsTemplateRegistrationDescription>
  </content>
</entry>

The error message apparently means that the request is missing required XML elements. The problem in my case was the capitalization:

Both WNSHeader and WNSHeaders should be written in Pascal case instead: WnsHeader and WnsHeaders.

Unfortunately Microsoft's documentation on the API is misleading regarding this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!