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

HttpCode 400 when upserting a member #49

Open
stashix opened this issue Feb 28, 2019 · 0 comments
Open

HttpCode 400 when upserting a member #49

stashix opened this issue Feb 28, 2019 · 0 comments

Comments

@stashix
Copy link

stashix commented Feb 28, 2019

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":"[email protected]",
   "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":"[email protected] 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? :)

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

No branches or pull requests

1 participant