List api problem


Hello, I'm using list api to insert contact into static list but although hubspot send me http 200 as response, my contact isn't entered into my list.
Here is my code:

private bool _addContactToList(int idlist, string email) {

  var endpoint = $"{idlist}/add?hapikey=myapikey";

  var json = JsonConvert.SerializeObject(new { email = new List<string>() { email} });

  HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(endpoint);
  request.Method = "POST";
  request.ContentType = "application/json";

  using (var streamWriter = new StreamWriter(request.GetRequestStream())) {

  HttpWebResponse response = (HttpWebResponse)request.GetResponse();

  string target = "";

  StreamReader streamReader = new StreamReader(response.GetResponseStream(), true);
    target = streamReader.ReadToEnd();

  if (response.StatusCode == HttpStatusCode.OK) return true;

  return false;

My request body is: {"emails":[""]}
And hubspot response body is this: {"updated":[],"discarded":[],"invalidVids":[],"invalidEmails":[]}
I also tried to encode my json into ASCII and send it as byte array but nothing happened


Hi @guidifra,

Can you send me a link to the list in HubSpot you're trying to add contacts to?


Yes @Derek_Gervais :


Hi @guidifra,

Very strange; I created myself as a test contact and was able to successfully add myself to one of those lists (the first one listed above). Do the emails you're including in the POST body exist as contacts? Is it possible that the request body is somehow getting malformed? The response you mentioned is what I would expect to see if we received a request with out any vids or emails.


Hi @Derek_Gervais,
Yes, the email I use is one of an existing contact because first of all I create a new contact with form api successfully and then I use the same email to put it into my list.


Hi @guidifra,

How much time is there between when the form submission is sent to HubSpot and when you make the request to add the contact to the list? I'm wondering if perhaps there's a race condition where the contacts backend hasn't had enough time to finish creating the contact when it receives your request to add the contact to the list?


Hi @Derek_Gervais, the time between form submission and request to add contact to the list is less then 1secs.. I'd try to run list add function after few minutes