title: Mailchimp add tags to existing member in a list with php and drupal 8
body: <p>I would like to add a tag to a member in a mailchimp list in Drupal 8 after adding the member to the list. I use PHP.</p>
  <p>Based upon the info I found at:
  <a href="https://mailchimp.com/developer/guides/organize-contacts-with-tags/#label-a-contact-with-a-tag" rel="nofollow noreferrer">https://mailchimp.com/developer/guides/organize-contacts-with-tags/#label-a-contact-with-a-tag</a></p>
  <p>Below code is working:</p>
  <pre><code>$response_tags = $mailchimp-&gt;lists-&gt;getListMemberTags($list_id, $subscriber_hash);
  \Drupal::logger('mailchimp_get_tags')-&gt;notice('&lt;pre&gt;&lt;code&gt;' . print_r($response_tags, TRUE) . '&lt;/code&gt;&lt;/pre&gt;');
  
  
  stdClass Object
  (
      [tags] =&gt; Array
          (
              [0] =&gt; stdClass Object
                  (
                      [id] =&gt; ****
                      [name] =&gt; 1_year
                      [date_added] =&gt; 2020-09-30T14:09:29+00:00
                  )
  
          )
  
      [total_items] =&gt; 1
  )
  </code></pre>
  <p>But below code is giving 400 bad request error ...</p>
  <pre><code>$mailchimp-&gt;lists-&gt;updateListMemberTags($list_id, $subscriber_hash, [
     &quot;tags&quot; =&gt; [
       &quot;name&quot; =&gt; &quot;my_new_tag&quot;,
       &quot;status&quot; =&gt; &quot;active&quot;
     ]
  ]);
  </code></pre>
  <p>Error:</p>
  <p>GuzzleHttp\Exception\ClientException: Client error: <code>POST https://***.api.mailchimp.com/3.0/lists/***/members/***/tags</code> resulted in a <code>400 Bad Request</code> response: {&quot;type&quot;:&quot; <a href="http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/" rel="nofollow noreferrer">http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/</a> &quot;,&quot;title&quot;:&quot;Invalid Resource&quot;,&quot;stat (truncated...) in GuzzleHttp\Exception\RequestException::create() (line 113 of /home/d8/drupal-project/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php).</p>
  <p>=&gt; <a href="https://mailchimp.com/developer/guides/marketing-api-conventions/#error-glossary" rel="nofollow noreferrer">https://mailchimp.com/developer/guides/marketing-api-conventions/#error-glossary</a></p>
  <p>The <strong>list_id</strong> is correct, the <strong>hash</strong> is correct but adding a tag to an existing member in the mailchimp list is not working.</p>