<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Http error 400 attempting to use $hubspot-&amp;gt;emailSubscription()-&amp;gt;updateSubscription() in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467440#M45386</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I'm trying to use the $hubspot-&amp;gt;emailSubscription()-&amp;gt;updateSubscription($email_addr,$data) method&amp;nbsp; as documented &lt;A href="https://legacydocs.hubspot.com/docs/methods/email/update_status" target="_blank" rel="noopener"&gt;here&lt;/A&gt; from php.&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I can get it to work to unsubscribe from all emails by setting data as:-&lt;/P&gt;&lt;P data-unlink="true"&gt;$data = ["unsubscribeFromAll" =&amp;gt; true];&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;However by requirement is to be able to unsubscribe from a given category by id using:-&lt;/P&gt;&lt;P data-unlink="true"&gt;$data = [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "subscriptionStatuses" =&amp;gt; [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id" =&amp;gt; $MARKETING_SUBS_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "optState" =&amp;gt; "OPT_OUT"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]&lt;BR /&gt;];&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;or&lt;/P&gt;&lt;P data-unlink="true"&gt;$data = [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "subscriptionStatuses" =&amp;gt; [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id" =&amp;gt; $MARKETING_SUBS_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "subscribed" =&amp;gt; false&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]&lt;BR /&gt;];&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;But nothing works, I get error code 400 - Bad request.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jul 2021 15:26:17 GMT</pubDate>
    <dc:creator>NFortin</dc:creator>
    <dc:date>2021-07-27T15:26:17Z</dc:date>
    <item>
      <title>Http error 400 attempting to use $hubspot-&gt;emailSubscription()-&gt;updateSubscription()</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467440#M45386</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I'm trying to use the $hubspot-&amp;gt;emailSubscription()-&amp;gt;updateSubscription($email_addr,$data) method&amp;nbsp; as documented &lt;A href="https://legacydocs.hubspot.com/docs/methods/email/update_status" target="_blank" rel="noopener"&gt;here&lt;/A&gt; from php.&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I can get it to work to unsubscribe from all emails by setting data as:-&lt;/P&gt;&lt;P data-unlink="true"&gt;$data = ["unsubscribeFromAll" =&amp;gt; true];&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;However by requirement is to be able to unsubscribe from a given category by id using:-&lt;/P&gt;&lt;P data-unlink="true"&gt;$data = [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "subscriptionStatuses" =&amp;gt; [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id" =&amp;gt; $MARKETING_SUBS_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "optState" =&amp;gt; "OPT_OUT"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]&lt;BR /&gt;];&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;or&lt;/P&gt;&lt;P data-unlink="true"&gt;$data = [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "subscriptionStatuses" =&amp;gt; [&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id" =&amp;gt; $MARKETING_SUBS_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "subscribed" =&amp;gt; false&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]&lt;BR /&gt;];&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;But nothing works, I get error code 400 - Bad request.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 15:26:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467440#M45386</guid>
      <dc:creator>NFortin</dc:creator>
      <dc:date>2021-07-27T15:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Http error 400 attempting to use $hubspot-&gt;emailSubscription()-&gt;updateSubscription()</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467536#M45391</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/214677"&gt;@NFortin&lt;/a&gt;, Are you sending the data by using CURL? If you JSON encoded your PHP var, what happens if you `print_r` the result? Would you be able to share that output?&lt;BR /&gt;&lt;BR /&gt;There is a big warning in the documentation that tells you that you can not subscribe / unsubscribe a contact that you have unsubscribed before using `&lt;SPAN&gt;["unsubscribeFromAll" =&amp;gt; true];`. Are you testing with another contact? Could be the issue as well.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 17:27:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467536#M45391</guid>
      <dc:creator>Teun</dc:creator>
      <dc:date>2021-07-27T17:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Http error 400 attempting to use $hubspot-&gt;emailSubscription()-&gt;updateSubscription()</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467977#M45413</link>
      <description>&lt;P&gt;I was not sending data by CURL, or not directly anyway, but using the methods detailed above. The warning about previously unsubscribed from all did not apply.&lt;/P&gt;&lt;P&gt;I've given up on getting that method working, I wonder if its deprecated?&lt;/P&gt;&lt;P&gt;I'm now using &lt;A href="https://developers.hubspot.com/docs/api/marketing-api/subscriptions-preferences" target="_blank" rel="noopener"&gt;this&lt;/A&gt; instead - which does work, so I've worked around the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 10:29:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Http-error-400-attempting-to-use-hubspot-gt-emailSubscription-gt/m-p/467977#M45413</guid>
      <dc:creator>NFortin</dc:creator>
      <dc:date>2021-07-28T10:29:57Z</dc:date>
    </item>
  </channel>
</rss>

