AnsweredAssumed Answered

POST request with JSON data from Google Apps Script

Question asked by Brian Bennett on May 10, 2018

I'm working with the Canvas API and Google Apps Script (JS based). There are some examples of using Apps Script from InstructureCon 2016, but many of those were GET requests rather than POST. I also found this thread, but it hasn't resolved my issue.

 

I'm playing with creating a Page just because it's easy. I've tried several structures based on the suggestions I've found, none of which have worked. Using:

 

{
  wiki_page: {
      title: "New Page",
      body:"A new page"
   }
}

returns a 500 error. Moving wiki_page to the top level returns a 422 error. I've also tried setting the contentLength property, which also fails. URL encoding, however, works.

 

Is there a way to post to the API using JSON objects as payloads rather than URL encoding a string? If so, what am I overlooking?

Outcomes