pratik0809 / GSheetsToMailchimp

A script written for Google Sheets that allows you to send edits on your spreadsheet to Mailchimp merge fields instantly.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Invalid Resource","status":400,"detail":"Blank email address","instance

mirandashort opened this issue · comments

I keep receiving this error in the execution logs when I edit a cell in my sheet. I'm not sure what I need to fix, as I do have all the variables properly aligned. Checked all over stackoverflow and my question on SO hasn't been getting responses.

Here are my vars for the mailchimp function:

var payload =  JSON.stringify({ 
"status_if_new": "subscribed", 
"email_address": email,
"merge_fields": {
    "LEAD": lead,
    "LATECOUNT": latecount,
    "CALLOFFCNT": calloffcnt,
    "WFHCNT": wfhcnt,
    "WFHOCCUR": wfhoccur,
    "WFHREMAIN": wfhremain,
    "ANNCALLOFF": anncalloff,
    "OCCURTOTAL": occurtotal,
    "USEDPTO": usedpto,
    "USEDSICK": usedsick,
    "PTOREMAIN": ptoremain,
    "SICKREMAIN": sickremain
}
});

And then this is the cadence for the the google sheet part:

else {
  //capture values specifically of the row that was edited
  var values = sheet.getRange(rowedited, 1, 1, 13).getValues()[0];
  //separate values variable
   var em = values[2];
   var email = values[2]
   var lead = values[1];
   var latecount = values[6];
   var calloffcnt = values[7];
   var wfhcnt = values[8];
   var wfhoccur = values[9];
   var wfhremain = values[10];
   var anncalloff = values[11];
   var occurtotal = values[21];
   var usedpto = values[22];
   var usedsick = values[23];
   var ptoremain = values[24];
   var sickremain = values[25];      
  sendToMailChimp_(em,email,lead,latecount,calloffcnt,wfhcnt,wfhoccur,wfhremain,anncalloff,occurtotal,usedpto,usedsick,ptoremain,sickremain);

I have the email variable twice because I was trying to find if there was a conflict with the email and subscriber hash, but anyway way I run it, I still get the blank email error.

Neeever mind, I was a big dummy and started my array at 1, not 0!