Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.
This repository was archived by the owner on Sep 1, 2021. It is now read-only.

HttpCode 400 when upserting a member #49

@stashix

Description

@stashix

Hello, I'm trying to update (both resubscribe and change some merge fields) a couple members.
Sending a PUT request to
https://<br>.api.mailchimp.com/3.0/lists/{listId}/members/{hashedEmail}
with a payload of:

{
   "email_address":"test1@test.cz",
   "merge_fields":{
      "LATITUDE":"17,4",
      "LONGITUDE":"12",
      "BIRTHDATE":"02\/14\/1988",
      "CREDLIM":"200,00",
      "EXRATE":"1",
      "FIRSTNAME":"Test1a",
      "NAMETITLE":"Test1 Contact1 works as Poskok",
      "GENDER":"Male",
      "LASTNAME":"Contact1a",
      "MOBILE":"+31685646587a",
      "NUMCHILD":0,
      "ACCNAME":"Test Account 1",
      "ACCNAMELK":"Test Account 1",
      "WEBURL":"https:\/\/www.test.cz",
      "ADDRESS":{
         "addr1":"somewhere",
         "addr2":"16",
         "city":"somewhere",
         "country":"NL",
         "state":"",
         "zip":"21658"
      }
   },
   "status":"subscribed",
   "status_if_new":"subscribed"
}

I'll get an error

{
   "type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
   "title":"Member Exists",
   "status":400,
   "detail":"test1@test.cz is already a list member. Use PUT to insert or update list members.",
   "instance":"85c2fcb7-c094-4d00-85d8-3db71bff8622"
}

which doesn't really make any sense - I'm already using a PUT request.
I'm sending the request like this, don't really see anything wrong:

Member member = ToMember(mappedEntity, false);
string payload = _serializer.SerializeObject(member);

using (MD5 md5 = MD5.Create())
{
    byte[] hashedMailByteArray = md5.ComputeHash(Encoding.UTF8.GetBytes(mappedEntity.Email.ToLower()));
    string hashedEmail = HttpServerUtility.UrlTokenEncode(hashedMailByteArray);
    HttpResponseMessage response = await _httpClient.PutAsync($"lists/{listId}/members/{hashedEmail}",
        new StringContent(payload, Encoding.UTF8, "application/json"));

    string responseBody = await response.Content.ReadAsStringAsync();
}

Anybody knows what I'm doing wrong? :)

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