Skip to content

Commit

Permalink
set ETag to overwrite when updating or deleting a registration
Browse files Browse the repository at this point in the history
The ETag needs to be set to "*" when updating or deleting a
registration, otherwise it returns
"Error 412 Precondition Failed–ETag header missing or invalid"

This is according to the code in Microsoft.WindowsAzure.Messaging.dll,
which is the Notification Hub client for Windows Phone
  • Loading branch information
Andrei Nitescu committed Dec 9, 2014
1 parent 77070ad commit d9d098d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/ByteSmith.WindowsAzure.Messaging/NotificationHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public Task UnregisterAsync(Registration registration)
if (String.IsNullOrEmpty(registration.RegistrationId))
throw new ArgumentException("RegistrationId missing.", "registration");

registration.ETag = "*";
return DeleteRegistration(registration);
}
catch (Exception ex)
Expand Down Expand Up @@ -301,6 +302,7 @@ private async Task<Registration> Register(Registration registration)

if (localRegistration != null) {
try {
localRegistration.ETag = "*";
registration = await UpdateRegistration (localRegistration);
} catch (WebException ex) {
if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
Expand All @@ -324,6 +326,7 @@ private async Task Unregister(string templateName)
if (registration == null)
return;

registration.ETag = "*";
await DeleteRegistration(registration);

DeleteLocalRegistration(templateName);
Expand Down

0 comments on commit d9d098d

Please sign in to comment.