Hi there,
I have started setting up a Google Script environment to handle certain things via the Canvas API for my team.
So far, I created only POST/PUT requests which are working just fine. Now I wanted to implement a GET request, however, the response returns HTML code instead of JSON data. The request works fine in Postman and a NodeJS version as well, so I'm sure I'm missing something in GScript. Did anyone encounter this issue? Below is my sample code.
function getRequestTest() {
var url = `myUrl.com/api/v1/courses/2555/users`;
var token = "myToken";
var options = {
method : "get",
contentType: "application/json",
payload : JSON.stringify(data),
headers : { Authorization: "Bearer " + token },
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(url, options).getContentText();
Logger.log(response);
}
The Logger literally prints out the HTML code of the course page.
Thanks for your help in advance!
Tamas