Cannot update sms confirmation notification preference with API

jeremy_sias
Community Novice

I'm trying to update notification preferences for an email communication channel using the API. There are some 90+ notification preferences, and the update command is working for all except for confirm_sms_communication_channel

The sample below succeeds in updating preferences for the fields used.

The code I'm using is C#

static async void updatePreferences(string sis_user_id, string channel_id)
{
string requestUri = $"api/v1/users/self/communication_channels/{channel_id}/notification_preferences?as_user_id=sis_user_id:{sis_user_id}";
FormUrlEncodedContent content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("notification_preferences[new_announcement][frequency]", "immediately"),
new KeyValuePair<string, string>("notification_preferences[assignment_due_date_changed][frequency]", "weekly"),
new KeyValuePair<string, string>("notification_preferences[confirm_email_communication_channel][frequency]", "immediately"), "immediately"),
});
HttpResponseMessage response = await client.PutAsync(
requestUri, content);
string message = await response.Content.ReadAsStringAsync();
Console.WriteLine(message);
if (response.IsSuccessStatusCode)
{Console.WriteLine("Success");}
else
{Console.WriteLine("Fail");}
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The result of this function is a success:

{&quot;notification_preferences&quot;_[{&quot;frequency&quot;_&quot;immediately&quot;,&quot;notification&quot;_&quot;new_announcement&quot;,&quot;category&quot;_&quot;announcement&quot;&#125;,{&quot;frequency&quot;_&quot;weekly&quot;,&quot;notification&quot;_&

It is also a success if I include the 90 or so other notification preferences.

However, if I include the confirm_sms_communication_channel as part of the key value pair it breaks the whole thing

new KeyValuePair<string, string>("notification_preferences[confirm_sms_communication_channel][frequency]", "immediately")‍‍

When adding the above KeyValuePair the result is that "The specified resource does not exist."

example of error message

I know for a fact that it should exist because when you get a full list of notification_preferences it is included in the response. Below is a fraction of that result.

{
"frequency": "immediately",
"notification": "confirm_email_communication_channel",
"category": "registration"
},
{
"frequency": "immediately",
"notification": "confirm_sms_communication_channel",
"category": "registration"
},‍‍‍‍‍‍‍‍‍‍

I also tried updating the sms notification preference using the single call format, which works for any other notification type.

static async void updatePreference(string sis_user_id, string channel_id, string notification)
{
string requestUri = $"api/v1/users/self/communication_channels/{channel_id}/notification_preferences/confirm_sms_communication_channel?as_user_id=sis_user_id:{sis_user_id}";
FormUrlEncodedContent content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("notification_preferences[frequency]", "immediately")
});
HttpResponseMessage response = await client.PutAsync(
requestUri, content);
string message = await response.Content.ReadAsStringAsync();
Console.WriteLine(message);
//preferences = await response.Content.ReadAsAsync<List<NotificationPreference>>();
if (response.IsSuccessStatusCode)
{Console.WriteLine("Success");}
else
{Console.WriteLine("Fail");}
}

But for confirm_sms_communication_channel i get the same result

example of error message

and even tried categories, which works for other categories such as late_grading, but it fails for the registration category

string requestUri = $"api/v1/users/self/communication_channels/{channel_id}/notification_preference_categories/registration?as_user_id=sis_user_id:{sis_user_id}";
FormUrlEncodedContent content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("notification_preferences[frequency]", "immediately")
});
‍‍‍‍‍

This is kind of baffling. Has anyone else run into this problem?

Labels (1)
0 Likes