title: POST request and 405 error in Google Apps Script
body: <p>I have some troubles with headers in GAS. I use an API which require Cookie for POST requests. When, i try it with Postman it works but with the script I still receive an 405 error :/</p>
  
  <p>First of all, I make a login request which return a cookie like this one : <code>JSESSIONID=D55B09A9076826AB6FC35B79B803C3F4; Path=/lambdapath; Secure; HttpOnly,authash=29cb2e5466f8a923da588fa55914fd72</code></p>
  
  <p>Then, I build a POST request like this :</p>
  
  <pre><code>function createObject(body, cookie) {
    var options = {
      'method': 'post',
      'contentType': 'application/json',
      'Cookie': cookie,
      'payload' : JSON.stringify(body)
    }
    var header = { 'headers': options }
    try {
     var response = UrlFetchApp.fetch("https://urlOftheAPI/create", header); 
      Logger.log('Saved one item :' + response.getResponseCode())
      return response.getResponseCode();
    } catch(err) {
      throw new Error(err); 
    }
  }
  </code></pre>
  
  <p>When I log the header it returns this :</p>
  
  <pre><code>"headers": {
      "method": "post",
      "contentType": "application/json",
      "Cookie": "JSESSIONID=D55B09A9076826AB6FC35B79B803C3F4; Path=/lambdapath; Secure; HttpOnly,authash=29cb2e5466f8a923da588fa55914fd72",
      "payload": "{\"foo\":\"bar\"}"
    }
  } 
  </code></pre>
  
  <p>Thanks for your help :)</p>
  
  <h1>EDIT</h1>
  
  <p>Thanks to @DimuDesign. It works when passing options with this format : </p>
  
  <pre><code> var options = {
      'method': 'post',
      'contentType': 'application/json',
      'headers': {
        'cookie': 'JSESSIONID=D55B09A9076826AB6FC35B79B803C3F4; Path=/lambdapath; Secure; HttpOnly,authash=29cb2e5466f8a923da588fa55914fd72'
      },
      'payload' : JSON.stringify(body)
    }
  </code></pre>