title: Salesforce Bulk Job CSV Upload via Google Apps Script UrlFetchApp
body: <p>I'm attempting to use Google Apps Script to access Salesforce's Bulk API 2.0 and <a href="https://developer.salesforce.com/docs/atlas.en-us.api_bulk_v2.meta/api_bulk_v2/upload_job_data.htm" rel="nofollow noreferrer">upload the CSV data to a job</a>, however Salesfore is returning</p>
  
  <p><code>[{"errorCode":"METHOD_NOT_ALLOWED","message":"HTTP Method 'GET' not allowed. Allowed are PUT"}]</code></p>
  
  <p>Given my experience with the Salesforce API, I highly doubt the issue is actually with the method type, but that there is some other validation which is causing this error. However, upon inspection of the request body and comparing it to what I <em>successfully</em> submit through cURL, I don't see what I can do to resolve.</p>
  
  <p>The request code:</p>
  
  <pre><code>var headers = {
    "Authorization": "Bearer TOKEN"
  };
  var options = {
    "method": "put",
    "contentType": "text/csv",
    "headers": headers,
    "payload": "Id,Entity_Name__c\n001,One\n002,Two\n003,Three"
  };
  var url = INSTANCE + "/services/data/v44.0/jobs/ingest/" + JOB_ID + "/batches";
  UrlFetchApp.fetch(url, options);
  </code></pre>
  
  <p>Google Apps Script request as returned via <a href="https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#getrequesturl" rel="nofollow noreferrer"><code>getRequest()</code></a>:</p>
  
  <pre><code>{
    "headers": {
      "Authorization": "Bearer TOKEN"
    },
    "method": "put",
    "payload": "Id,Entity_Name__c\n001,One\n002,Two\n003,Three",
    "followRedirects": true,
    "validateHttpsCertificates": true,
    "useIntranet": false,
    "contentType": "text/csv",
    "url": "INSTANCE/services/data/v44.0/jobs/ingest/JOB_ID/batches"
  }
  </code></pre>
  
  <p>cURL request:</p>
  
  <pre><code>curl --request PUT \
    --url INSTANCE/services/data/v44.0/jobs/ingest/JOB_ID/batches \
    --header 'authorization: Bearer TOKEN' \
    --header 'content-type: text/csv' \
    --data '"Id,Entity_Name__c\n001,One\n002,Two\n003,Three"'
  </code></pre>
  
  <p>How can I resolve this?</p>