无法将订阅者添加到组 MailChimp API 3.0 C#

Can't add subscriber to group MailChimp API 3.0 C#

当我想为兴趣添加订阅者时,将布尔值设置为 true,它仍然是 false。我使用类似的请求更新合并字段值没有问题。调试时我注意到两者之间的一个区别,即兴趣在请求中有 "key" 和 "value" 而合并字段没有:

关于兴趣的响应看起来像这样,它也没有 "key" 和 "value"。

我做错了什么?

我的 updateMember 函数的相关部分如下所示:

static void updateMember(){
    Dictionary<string, object> mergefieldsDic = new Dictionary<string, object>();
    mergefieldsDic.Add("POSTCODE","4242");

    Dictionary<string, bool> interestDic = new Dictionary<object, bool>();
    interestDic.Add("cb0b422bf8", true);

    request.RequestFormat = DataFormat.Json;
    request.AddBody(new MemberRequest(mergefieldsDic, interestDic));

    IRestResponse<Member> response = client.Execute<Member>(request);

    foreach (var key in response.Data.merge_fields.Keys)
    {
        string value = response.Data.merge_fields[key].ToString();
        Console.WriteLine(value);
    }
    foreach (var key in response.Data.interests.Keys)
    {
        string value = response.Data.interests[key].ToString();
        Console.WriteLine(value);
    }
}

我的 MemberRequest class 看起来像这样

public class MemberRequest
{
    public MemberRequest(){}
    public MemberRequest(Dictionary<string, object> merge_fields, Dictionary<object, bool> interests)
    {
        this.merge_fields = merge_fields;
        this.interests = interests;
    }
    public string email_address { get; set; }
    public string status { get; set; }
    public Dictionary<string,object> merge_fields { get; set; }
    public Dictionary<object, bool> interests { get; set; }
}

我的会员class看起来像这样

public class Member
{
    public string id { get; set; }
    public string email_address { get; set; }
    public string status { get; set; }
    public Dictionary<string,object> merge_fields { get; set; }
    public Dictionary<object,bool> interests { get; set; }
}

我尝试将双方兴趣词典更改为 <bool,object>\<string,bool><string,string>,但没有任何效果。

如果我不使用 MemberRequest class 并且只执行 request.AddBody(new { interests = new { cb0b422bf8 = true} });

,我设法让它工作

出于某种原因,我在更新成员时没有收到错误,但是当我尝试使用上述 类 创建新成员时,我收到了来自 API 的错误请求兴趣是一个数组而不是一个对象,因为它必须是。为了解决这个问题,我将兴趣 Dictionary<string,bool> 更改为 Dictionary<string,object>

最初,当我更改字典时,我得到了两个几乎相同的构造函数,因此我的错误是 "The call is ambiguous between the following methods or properties"。