<?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 Re: API / Add contacts to a static list in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458246#M45003</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/175253"&gt;@AbdelMOULIDA&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;Any possibility of printing out what the json body looks like that you are sending?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 14:48:34 GMT</pubDate>
    <dc:creator>dennisedson</dc:creator>
    <dc:date>2021-07-13T14:48:34Z</dc:date>
    <item>
      <title>API / Add contacts to a static list</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458095#M44990</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;Context&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;:&lt;BR /&gt;Every week I do two to three contact imports that I add to a statistical list afterwards to trigger a workflow (send emails).&lt;BR /&gt;I want to automate these imports using Python/API-HubSpot.&lt;BR /&gt;I coded a code that doesn't work, I don't really understand where the error comes from.&lt;/P&gt;&lt;P&gt;What I want to do: import contacts on HubSpot with the API and then add them in my static list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;My code&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;:&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;AddList = "&lt;A href="https://api.hubapi.com/contacts/v1/lists/LIST_ID/add?hapikey=API-Key" target="_blank" rel="noopener"&gt;https://api.hubapi.com/contacts/v1/lists/LIST_ID/add?hapikey=API-Key&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;emailList = ""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with open("contacts - in.csv") as csv_file:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; csv_reader = csv.reader(csv_file, delimiter=',')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; line_count = 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for row in csv_reader:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # This will skip the header row;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if line_count == 0:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; line_count += 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pass&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# My emails happen to be in column c, you may need to change this.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# If the csv file is open in excel column A = 0, B = 1, C = 2, D = 3...&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;emailList += "\""+row[2] + "\",\n"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;line_count += 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mydata = """{&lt;BR /&gt;"vids": [],&lt;BR /&gt;"emails": [&lt;BR /&gt;"""+emailList[:-2]+""" #This will remove the extra spaces and characters at the end&lt;BR /&gt;]&lt;BR /&gt;}"""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;headers = {'content-type': 'application/json'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;response = requests.request("POST", AddList, headers = headers, data = mydata)&lt;BR /&gt;print(response.text.encode('utf8'))&lt;BR /&gt;print(response.status_code)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;ERROR:&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AbdelMOULIDA_0-1626177209370.png" style="width: 477px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/46155i3C380184ADF89EF3/image-dimensions/477x31?v=v2" width="477" height="31" role="button" title="AbdelMOULIDA_0-1626177209370.png" alt="AbdelMOULIDA_0-1626177209370.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 11:54:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458095#M44990</guid>
      <dc:creator>AbdelMOULIDA</dc:creator>
      <dc:date>2021-07-13T11:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: API / Add contacts to a static list</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458246#M45003</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/175253"&gt;@AbdelMOULIDA&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;Any possibility of printing out what the json body looks like that you are sending?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 14:48:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458246#M45003</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-07-13T14:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: API / Add contacts to a static list</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458269#M45006</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;, thanks for your feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the contact already exist on HubSpot (It works):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AbdelMOULIDA_0-1626188628176.png" style="width: 550px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/46179iDEB310BF17A39A31/image-dimensions/550x40?v=v2" width="550" height="40" role="button" title="AbdelMOULIDA_0-1626188628176.png" alt="AbdelMOULIDA_0-1626188628176.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If the contact doesn't exist on HubSpot, I have this error and the contact is not created:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AbdelMOULIDA_2-1626188748297.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/46181i5AA7CD85183DD62E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AbdelMOULIDA_2-1626188748297.png" alt="AbdelMOULIDA_2-1626188748297.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 15:07:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458269#M45006</guid>
      <dc:creator>AbdelMOULIDA</dc:creator>
      <dc:date>2021-07-13T15:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: API / Add contacts to a static list</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458859#M45033</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/175253"&gt;@AbdelMOULIDA&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN data-sheets-value="{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:&amp;quot;your input data contains \&amp;quot;#\&amp;quot; inside it which is a special character and need to be escaped.Do the string escaping of your content before passing the info through json.&amp;quot;}" data-sheets-userformat="{&amp;quot;2&amp;quot;:829,&amp;quot;3&amp;quot;:{&amp;quot;1&amp;quot;:0},&amp;quot;5&amp;quot;:{&amp;quot;1&amp;quot;:[{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0,&amp;quot;5&amp;quot;:{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0}},{&amp;quot;1&amp;quot;:0,&amp;quot;2&amp;quot;:0,&amp;quot;3&amp;quot;:3},{&amp;quot;1&amp;quot;:1,&amp;quot;2&amp;quot;:0,&amp;quot;4&amp;quot;:1}]},&amp;quot;6&amp;quot;:{&amp;quot;1&amp;quot;:[{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0,&amp;quot;5&amp;quot;:{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0}},{&amp;quot;1&amp;quot;:0,&amp;quot;2&amp;quot;:0,&amp;quot;3&amp;quot;:3},{&amp;quot;1&amp;quot;:1,&amp;quot;2&amp;quot;:0,&amp;quot;4&amp;quot;:1}]},&amp;quot;7&amp;quot;:{&amp;quot;1&amp;quot;:[{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0,&amp;quot;5&amp;quot;:{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0}},{&amp;quot;1&amp;quot;:0,&amp;quot;2&amp;quot;:0,&amp;quot;3&amp;quot;:3},{&amp;quot;1&amp;quot;:1,&amp;quot;2&amp;quot;:0,&amp;quot;4&amp;quot;:1}]},&amp;quot;8&amp;quot;:{&amp;quot;1&amp;quot;:[{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0,&amp;quot;5&amp;quot;:{&amp;quot;1&amp;quot;:2,&amp;quot;2&amp;quot;:0}},{&amp;quot;1&amp;quot;:0,&amp;quot;2&amp;quot;:0,&amp;quot;3&amp;quot;:3},{&amp;quot;1&amp;quot;:1,&amp;quot;2&amp;quot;:0,&amp;quot;4&amp;quot;:1}]},&amp;quot;11&amp;quot;:4,&amp;quot;12&amp;quot;:0}"&gt;Your input data contains "#" inside it which is a special character and need to be escaped.Do the string escaping of your content before passing the info through json.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Hope this helps!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;If we were able to answer your query, kindly help the community by marking it as a solution.&lt;BR /&gt;&lt;BR /&gt;Thanks and Regards.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 09:55:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/458859#M45033</guid>
      <dc:creator>webdew</dc:creator>
      <dc:date>2021-07-14T09:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: API / Add contacts to a static list</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/459036#M45045</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/175253"&gt;@AbdelMOULIDA&lt;/a&gt; , the contact needs to exist before you can add it to the list.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 14:24:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/459036#M45045</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-07-14T14:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: API / Add contacts to a static list</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/460474#M45100</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510"&gt;@webdew&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, It works :).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 07:41:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Add-contacts-to-a-static-list/m-p/460474#M45100</guid>
      <dc:creator>AbdelMOULIDA</dc:creator>
      <dc:date>2021-07-16T07:41:27Z</dc:date>
    </item>
  </channel>
</rss>

