Trying to perform Update Opportunity by ID through Google App Scripts (GAS)

I am looking to update a few custom fields in Copper in a single call. As an example, I was successful using CURL to change the ‘details’ and ‘custom_field_definition_id’:

curl --location --request PUT "" \

  --header "X-PW-AccessToken: <<APITOKEN>>" \

  --header "X-PW-Application: developer_api" \

  --header "X-PW-UserEmail: <<EMAIL>" \

  --header "Content-Type: application/json" \

  --data "{

    \"details\":\"This is an update using CURL with Custom Fields\",

    \"custom_fields\": [


        \"custom_field_definition_id\": 637119,

        \"value\": 150





When I converted this code to GAS to change the same two fields to different values, I do not get an error and no change occurs to the fields.

apiUrl = "";

  options = {

    "headers": {

      "X-PW-AccessToken": CopperAPIkey,

      "X-PW-Application": "developer_api",

      "X-PW-UserEmail": "<<EMAIL>>",

      "Content-Type": "application/json"


    "method": 'PUT',

    "muteHttpExceptions": true,

    "data": {

      "details": "This is an update from Ira - 5",

      "custom_fields": [


          "custom_field_definition_id": 637119,

          "value": 175





  response = UrlFetchApp.fetch(apiUrl, options);

  data = JSON.parse(response.getContentText());


Can anyone provide insight as to what I am doing wrong in GAS?


0 replies

Be the first to reply!