samterfa / Schoology-Google-Apps-Scripts

These are a series of Google Apps Script functions I wrote to be able to read data from and write data to Schoology using API calls to Schoology's API from Google Apps Scripts
2 stars 1 forks source link

Courses only pulls headers, no data #1

Closed menkohgh closed 1 year ago

menkohgh commented 1 year ago

Thank you for creating this, it is super helpful. I was able to pull users, but when I try courses I only get the headers, but no data coming through. If I take the URL and try it in Postman, I get the error "Duplicate timestamp/nonce combination, possible replay attack. Request rejected." Is there a way to modify the code to work? Thanks!

samterfa commented 1 year ago

Sorry I don't really maintain this repo since I don't use Google Apps Scripts for this anymore. It looks like Schoology's API is not returning a "total" for the /courses endpoint like they used to and document here. This is causing a null value for the totalCourses value. You could probably use while(JSON.parse(response)['links']['next'] != null) or while(JSON.parse(response)['links'] != null) for the loop instead, but I don't really like while loops that could go on forever.

If you do want to try a request in Postman after already having run it in Google Apps Script, you will have to at least add one to the previous timestamp you used. You've basically "spent" that timestamp already. It is actually a replay like the error indicated, though not a malicious one.

menkohgh commented 1 year ago

Thanks Sam! I figured it was long past maintained, so appreciate you answering. If I get rid of the timestamp and nonce in postman I get 20 courses returned, but can’t seem to get it in the script. I have no experience with APIs but would love to get this data downloading into sheets which I am familiar with. Any help you can provide would be awesome, thanks in advance!

Menko

Menko Johnson Educational Technology Coordinator Fremont Union High School District (408) 522-2270

Schedule Time: https://calendly.com/menko_johnson https://calendly.com/menko_johnson Zoom: https://bit.ly/2FpGzPL Schoology for Staff: https://fuhsd.schoology.com/course/2691403064/materials

On May 9, 2023, at 6:42 PM, Sam Terfa @.**@.>> wrote:

Sorry I don't really maintain this repo since I don't use Google Apps Scripts for this anymore. It looks like Schoology's API is not returning a "total" for the /courses endpoint like they used to and document herehttps://urldefense.com/v3/__https://developers.schoology.com/api-documentation/rest-api-v1/course__;!!AO96v2w!ZIUTvtzcDp_-l_9jiHz52DBynlQzzAS49FDTYEfzWSubZdPRqHIVRulVWdgFkjovVD-Dj9pNq9eRD2IN7z7AWWGvszb9$. This is causing a null value for the totalCourses value. You could probably use while(JSON.parse(response)['links']['next'] != null) or while(JSON.parse(response)['links'] != null) for the loop instead, but I don't really like while loops that could go on forever.

If you do want to try a request in Postman after already having run it in Google Apps Script, you will have to at least add one to the previous timestamp you used. You've basically "spent" that timestamp already. It is actually a replay like the error indicated, though not a malicious one.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/samterfa/Schoology-Google-Apps-Scripts/issues/1*issuecomment-1541167751__;Iw!!AO96v2w!ZIUTvtzcDp_-l_9jiHz52DBynlQzzAS49FDTYEfzWSubZdPRqHIVRulVWdgFkjovVD-Dj9pNq9eRD2IN7z7AWSI4N98Q$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/A7WJQBIRK2NLNHEU6SACIHLXFLXBVANCNFSM6AAAAAAX2LUXPY__;!!AO96v2w!ZIUTvtzcDp_-l_9jiHz52DBynlQzzAS49FDTYEfzWSubZdPRqHIVRulVWdgFkjovVD-Dj9pNq9eRD2IN7z7AWZTFcvgt$. You are receiving this because you authored the thread.Message ID: @.***>