0

I am trying to use IFTTT Maker Channel to create a new text file in my dropbox, using Google Apps script. I mapped the "value1" and "value2" to the body of the file. Here is my sample code, without my api key.

function sendFileToMaker(){
  var makerKey = 'app_key';
  var eventName = 'Test_Event';
  var url = 'https://maker.ifttt.com/trigger/' + eventName + '/with/key/' + makerKey;
  var payload = {
    "value1" : "test",
    "value2" : "testFile"
  };
  
  var options = {
    "method" : "POST",
    "contentType": "json",
    "payload":payload,
  };
  Logger.log(UrlFetchApp.fetch(url,options));
  
};

The trigger runs, but the values do not seem to be recognized. I get "Congratulations! You've fired the Test_Event event", so it seem as if I did not get an error, but the file it creates is empty.

What am I doing worng? How do I fix it?

Community
  • 1
  • 1
Mullenb
  • 651
  • 6
  • 20

1 Answers1

1

I found what I did wrong. If you take out the content type, the call works. I edited the function so it would be easier to use.

function sendToMaker(makerKey,eventName,value1,value2,value3){
  var url = 'https://maker.ifttt.com/trigger/' + eventName + '/with/key/' + makerKey;
  var payload = {
    'value1' : value1,
    'value2' : value2,
    'value3' : value3
  };

  var options = {
    'method' : 'POST',
    'payload':payload,
  };
  return UrlFetchApp.fetch(url,options)
};

You can send text through to the Maker Channel, or download URLs so you can add files from Google Drive to Dropbox.

Mullenb
  • 651
  • 6
  • 20