Khan / khan-api

Documentation for (and examples of) using the Khan Academy API
http://www.khanacademy.org
377 stars 75 forks source link

400: Bad Request on /api/v1/user/exercises with a "large" list of exercise names #78

Open jb-1980 opened 9 years ago

jb-1980 commented 9 years ago

I am able to get a list of exercises using the form /api/v1/user/exercises?exercises=exercise1&exercises=exercise2..., but if I make the list too long I get a 400: Bad Request error. After researching it, I believe it has to do with a limit on the bytes of the URL. I am currently trying to get around 100 exercises, and it seems that the limit is ~50.

Is this a limit on the server side, and if it is can it be changed?

alangpierce commented 9 years ago

Yeah, it sounds like you're hitting a URL length limit. Unfortunately, I don't think there's anything I can do to raise the limit.

I agree that there shouldn't be a limit on the number of exercises you load at once (or, at least, the limit should be much bigger than 50). It looks like there are some possible workarounds, like allowing a POST request with the exercise list as the request body, but they would have to be implemented on the server. I can probably get something implemented in the next week or two.

Another thing you could try is to include the arguments in the request body (instead of the URL). Including a request body for GET requests is non-standard and some clients may not support it, and it's hard for me to test, but it's possible that it would work.