Skip to content

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

@bjarnef

Description

@bjarnef

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions