[ARCHIVED] Vanilla Javascript, Pages API call, & 401 error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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>");
}
})
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.