0

im trying to register my Mac APP to my Azure Notification Hub. I already can create a registration ID and now I just need to register. https://msdn.microsoft.com/de-de/library/azure/dn223265.aspx

I get always a 400 Bad Request response. Not sure where the problem is.

this is the code I'm using:

string payload = @"<?xml version=""1.0"" encoding=""utf-8""?><entry xmlns=""http://www.w3.org/2005/Atom""><content type=""application/xml""><AppleRegistrationDescription xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/netservices/2010/10/servicebus/connect""><Tags>myTag</Tags><DeviceToken>ABCDEFGHIJKLMNOPQRSTUVWXYZ</DeviceToken></AppleRegistrationDescription></content></entry>";
payload = payload.Replace("ABCDEFGHIJKLMNOPQRSTUVWXYZ", deviceToken);

var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("Authorization", SasToken);
client.DefaultRequestHeaders.Add("Accept", "application/atom+xml");
client.DefaultRequestHeaders.Add("x-ms-version", "2015-01");
HttpResponseMessage response = await client.PostAsync("https://" + HUB_NotificationHubNameSapce + ".servicebus.windows.net/" + HUB_NotificationHubPath + "/registrations/?api-version=2015-01", new StringContent(payload, Encoding.UTF8, "application/atom+xml"));

i don't believe it is the payload because I tried different ones, I think I make something wrong with the HttpClient.

  • 1
    Could you update the question with the exact payload and URL that gets generated? (With scrubbed connection strings/token.) It's possible it's the payload. Also, follow the [troubleshooting guide](https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-fixer) and update the post with what you've learned in case it still doesn't work. – Nikita R. Feb 21 '17 at 21:46
  • 2
    I just found the problem, the Tag format was wrong. "Tag1, Tag2" causes the problem. Should be "Tag1,Tag2" without space. The MS API Doc is wrong about that. thanks anyway – user1442727 Feb 23 '17 at 07:34
  • Removing entire tag section succeeded for me. – DevMonk May 28 '19 at 01:53

0 Answers0