Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get method fails if email doesn't exists in list #54

Open
bjarnef opened this issue Nov 21, 2017 · 1 comment
Open

Get method fails if email doesn't exists in list #54

bjarnef opened this issue Nov 21, 2017 · 1 comment

Comments

@bjarnef
Copy link

bjarnef commented Nov 21, 2017

If I use the Get method to get SubscriberDetail it fails if the email doesn't exist in the list.
If the user/email doesn't exist in the list I would expect it to return null.

If the user/email exists in the list (e.g. active or deleted) it returns an object with the correct state, but if the use doesn't already exist in the list, it doesn't continue in the code. E.g. in the following code sample the code doesn't reach the code with customFields or subscribe, which is not executed - only when the user/email already exists in the list.

I know the line with SubscriberDetail in the case is not necessary to subscribe the user to the list and if I remove this line it also works to subscribe users, who are not already in the list. However this line shouldn't prevent the rest of the code to be executed.

Subscriber subscriber = new Subscriber(_auth, _listId);

SubscriberDetail sd = subscriber.Get(model.Email);

List<SubscriberCustomField> customFields = new List<SubscriberCustomField>();
customFields.Add(new SubscriberCustomField() { Key = "AccountCreated", Value = "Ja" });

subscriber.Add(model.Email, null, customFields, true);

I guess it somewhere in this method fails to get the email/user or because the request fails.

public SubscriberDetail Get(string emailAddress)
{
NameValueCollection queryArguments = new NameValueCollection();
queryArguments.Add("email", emailAddress);
return HttpGet<SubscriberDetail>(
string.Format("/subscribers/{0}.json", ListID), queryArguments);
}

@bjarnef
Copy link
Author

bjarnef commented Nov 21, 2017

I get this exception in my log file.

 2017-11-21 08:24:11,143 [P18232/D13/T834] ERROR Test.Library.Helpers.CampaignMonitor - CampaignMonitor Error - status code: 203
createsend_dotnet.CreatesendException: The CreateSend API responded with the following error - 203: Subscriber not in list or has already been removed.
   ved createsend_dotnet.HttpHelper.MakeRequest[T,U,EX](String method, AuthenticationDetails auth, String path, NameValueCollection queryArguments, T payload, String baseUri, String contentType) i c:\Users\terryt\Projects\createsend-dotnet\createsend-dotnet\HttpHelper.cs:linje 222
   ved createsend_dotnet.HttpHelper.Get[U,EX](AuthenticationDetails auth, String baseUri, String path, NameValueCollection queryArguments) i c:\Users\terryt\Projects\createsend-dotnet\createsend-dotnet\HttpHelper.cs:linje 44
   ved createsend_dotnet.CreateSendBase.HttpGet[U,EX](String path, NameValueCollection queryArguments) i c:\Users\terryt\Projects\createsend-dotnet\createsend-dotnet\CreateSendBase.cs:linje 61
   ved createsend_dotnet.Subscriber.Get(String emailAddress) i c:\Users\terryt\Projects\createsend-dotnet\createsend-dotnet\Subscriber.cs:linje 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant