title: iContact API Create contact call in JS google script
body: <p>I'm trying to create a new contact through the <code>iContact API</code>.</p>
  
  <p>I got the error message as</p>
  
  <blockquote>
    <p>You did not provide an email field, which is required. Please provide
    an email field</p>
  </blockquote>
  
  <p>by running the following code with Google Apps Script. </p>
  
  <p>I guess the payload structure is not good, i tried other structures without success.</p>
  
  <pre><code>function sendHttpPost() {
  var headers= {
  "API-Username":"justsomebns@gmail.com",
  "API-AppId":"pkec8CCH3Rd5GJoYY52YMjfPZym1sIXI",
  "API-Version":"2.0",
  "API-Password":"4tpzgto4tpzgto",
  "Accept":"application/json"};
  var payload = 
      {contact: 
          { "contactId":64363721,
      "email":"joyvious@gmail.com",
      "prefix":"Mr.",
      "firstName":"Michael",
      "lastName":"Smith",
      "suffix":"Jr.",
      "street":"2365 Meridian Parkway",
      "street2":"",
      "city":"Durham",
      "state":"NC",
      "postalCode":27502,
      "phone":"8668039462",
      "fax":"",
      "business":"ABusiness",
      "createDate":"2009-06-18 22:39:54'",
      "bounceCount":0,
      "status":"normal",
     }
  }
      ;
  
    var options =
      {
        "headers" : headers,
        "method" : "POST",
        "payload" : payload,
        "timeout":5000
      };
  
  var res = UrlFetchApp.fetch("https://app.icontact.com/icp/a/{account_id}/c/{folder_id}/contacts/", options);
  
  Logger.log(res);
  }
  </code></pre>
  
  <p><code>iContact API</code> <a href="https://www.icontact.com/developerportal/documentation/contacts" rel="nofollow noreferrer">documentation link</a><br/>
  I get also the email issue when trying with the same code as this <a href="https://stackoverflow.com/questions/14008002/how-to-make-icontact-api-call-from-google-scripts">old post</a></p>