API Posting Using UrlFetchApp in Google Appscripts

Viewed 18

I'm currently trying to update an event in Eventbrite using Google Appscripts and the Eventbrite API. I've managed to 'get' and 'post' to urls that don't require input data, but I can't figure out how to do this. The example code provided by Eventbrite is this:

curl -X POST   https://www.eventbriteapi.com/v3/events/{event_id}/   -H 'Authorization: Bearer PERSONAL_OAUTH_TOKEN'   -H "Accept: application/json"
  -d '{
        "event": {
            "capacity": 200
            }
        }'

I know I can achieve this with Google Appscript code that looks something like this:

let info = {
    'capacity' : 200
  }

   var editOptions = {
    'method' : 'post',
    'contentType': 'application/json',
    'headers' : {'Authorization': 'Bearer ' + token},
    'payload' : JSON.stringify(info),
  };


  updated = UrlFetchApp.fetch('https://www.eventbriteapi.com/v3/events/' + event_id_new, editOptions);

However, the script completes but the fields are not being updated. As I said, I've managed to get and post where no data is required, meaning the authentication and event_id aren't the problem (as I'm using these successfully elsewhere in the code).

0 Answers
Related