[ARCHIVED] Vanilla Javascript, Pages API call, & 401 error

bertscjn1
Community Explorer

Hello community! 

I am making an API call to Pages and pulling the default 10 pages no problem. However, when I try to add the "per_page=" parameter I get a 401 error in the console! What's strange is that if I copy and paste the entire API URL into the omnibar, the call is made without issue and I can see all the pages - published and unpublished. What am I doing wrong? Here is my code for reference:

var modules = {
"url": "[my institution instance]/api/v1/courses/sis_course_id:" + CourseID +"/pages?per_page=30?access_token=" + API_Key,
}

$.ajax(modules).done(function (response) {
console.log(response);
$("#Modulepages").append("<h2>Modules </h2><br>")
for (i=0; i<50 i++){
var content = response[i].title;
$("#Modulepages").append(content + "<br>");
}

})

Labels (2)
0 Likes