title: Google Apps Script PUT requests failing
body: <p>I'm having issues with calling the <a href="https://streak.readme.io/v9/reference#put-an-email-in-a-box" rel="nofollow noreferrer">Streak API</a> with Google Apps Script.  Any of the GET or POST requests I make are working, but I can't get a single PUT request to work.</p>
  
  <p>Since the matching CURL requests work I'm thinking it's something I'm doing wrong with the GAS request?  Any help would be appreciated! </p>
  
  <p>For example this:</p>
  
  <pre><code>  var streakApiKey = "&lt;my-api-key&gt;";
    var streakBoxKey = "agxzfm1haWxmb29nYWVyLwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEgRDYXNlGKGs7kkM";
    var gmailThreadId = "1611ad242bc28086";
    var url = "https://www.streak.com/api/v1/boxes/" + streakBoxKey + "/threads/";
  
    var payload = {
      "boxKey": streakBoxKey,
      "threadGmailId": gmailThreadId
      };
  
    var headers = {
       "Accept": "application/json",
       "Content-Type": "application/json",
       "Authorization": "Basic "+ Utilities.base64Encode(streakApiKey + ":")
       };
  
    var options = {
      "method": "put",
      "headers": headers,
      "contentType" : "application/json",
      "payload": JSON.stringify(payload),
      "muteHttpExceptions" : true,
      };
  
    var request = UrlFetchApp.getRequest(url, options);
    Logger.log(request);
  
    var response = UrlFetchApp.fetch(url,options);
    Logger.log(response.getContentText());
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>[18-02-04 10:58:30:284 NZDT] {headers={Authorization=Basic &lt;my-encoded-api-key&gt;, Accept=application/json}, method=put, payload={"boxKey":"agxzfm1haWxmb29nYWVyLwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEgRDYXNlGKGs7kkM","threadGmailId":"1611ad242bc28086"}, followRedirects=true, validateHttpsCertificates=true, useIntranet=false, contentType=application/json, url=https://www.streak.com/api/v1/boxes/agxzfm1haWxmb29nYWVyLwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEgRDYXNlGKGs7kkM/threads/}
  [18-02-04 10:58:30:311 NZDT] {
    "success": false,
    "error": "Insufficient params for GmailThread. Missing json"
  }
  </code></pre>
  
  <p>But this CURL works:</p>
  
  <pre><code> curl --request PUT \  --url https://www.streak.com/api/v1/boxes/agxzfm1haWxmb29nYWVyLwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEgRDYXNlGKGs7kkM/threads \  --data 'boxKey=agxzfm1haWxmb29nYWVyLwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEgRDYXNlGKGs7kkM&amp;threadGmailId=1611ad242bc28086' -u &lt;my-api-key&gt;:
  </code></pre>
  
  <p>Similarly this fails:</p>
  
  <pre><code>var streakApiKey = "&lt;my-api-key&gt;";
    var pipelineKey = "agxzfm1haWxmb29nYWVyNwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEghXb3JrZmxvdxiAgICA1uaPCgw";
    var url = "https://www.streak.com/api/v1/pipelines/" + pipelineKey + "/stages";
  
    var payload = {
      "name": "new Stage from API",
      };
  
    var headers = {
       "Accept": "application/json",
       "Content-Type": "application/json",
       "Authorization": "Basic "+ Utilities.base64Encode(streakApiKey + ":")
       };
  
    var options = {
      "method": "put",
      "headers": headers,
      "contentType" : "application/json",
      "payload": JSON.stringify(payload),
      "muteHttpExceptions" : true,
      };
  
    var request = UrlFetchApp.getRequest(url, options);
    Logger.log(request);
  
    var response = UrlFetchApp.fetch(url,options);
    Logger.log(response.getContentText());
  </code></pre>
  
  <p>and returns:</p>
  
  <pre><code>[18-02-04 11:02:01:600 NZDT] {headers={Authorization=Basic &lt;my-encoded-api-key&gt;, Accept=application/json}, method=put, payload={"name":"new Stage from API"}, followRedirects=true, validateHttpsCertificates=true, useIntranet=false, contentType=application/json, url=https://www.streak.com/api/v1/pipelines/agxzfm1haWxmb29nYWVyNwsSDE9yZ2FuaXphdGlvbiIQd2hlZWx3b3Jrcy5jby5uegwLEghXb3JrZmxvdxiAgICA1uaPCgw/stages}
  [18-02-04 11:02:01:632 NZDT] {
    "success": false,
    "error": "Insufficient params for Stage"
  }
  </code></pre>