Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 400: Bad Request #568

Closed
M-Oliv3 opened this issue Dec 6, 2019 · 4 comments
Closed

Error 400: Bad Request #568

M-Oliv3 opened this issue Dec 6, 2019 · 4 comments

Comments

@M-Oliv3
Copy link

M-Oliv3 commented Dec 6, 2019

edx_dl version 0.1.10
Building initial headers for future requests.
Getting initial CSRF token.
Traceback (most recent call last):
File "edx-dl.py", line 6, in
edx_dl.main()
File "E:\edx\edx-dl-master\edx_dl\edx_dl.py", line 1000, in main
headers = edx_get_headers()
File "E:\edx\edx-dl-master\edx_dl\edx_dl.py", line 425, in edx_get_headers
'X-CSRFToken': _get_initial_token(EDX_HOMEPAGE),
File "E:\edx\edx-dl-master\edx_dl\edx_dl.py", line 167, in _get_initial_token
opener.open(url)
File "E:\Anaconda3\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "E:\Anaconda3\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "E:\Anaconda3\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "E:\Anaconda3\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "E:\Anaconda3\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

  • Operating System (Win10):
  • Python version: 3
  • youtube-dl version: last
  • edx-dl version: last

I'm trying to download from Edx, But I can't make the login. For example when I put : python edx-dl.py -u XXXXXX -p XXXXX --list-courses. or other command line, it shows the above error.

@robertoaceves
Copy link

Failing on macOS Mojave (10.14.6) too, Python 2.7.

edx-dl -u "[email protected]" --list-courses
edx_dl version 0.1.10
Password:
Building initial headers for future requests.
Getting initial CSRF token.
url: <https://courses.edx.org/login_ajax>
Traceback (most recent call last):
  File "/usr/local/bin/edx-dl", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/edx_dl/edx_dl.py", line 1001, in main
    headers = edx_get_headers()
  File "/usr/local/lib/python2.7/site-packages/edx_dl/edx_dl.py", line 426, in edx_get_headers
    'X-CSRFToken': _get_initial_token(EDX_HOMEPAGE),
  File "/usr/local/lib/python2.7/site-packages/edx_dl/edx_dl.py", line 168, in _get_initial_token
    opener.open(url)
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request

@robertoaceves
Copy link

robertoaceves commented Dec 6, 2019

Made some progress by changing the lines

EDX_HOMEPAGE = BASE_URL + '/user_api/v1/account/login_session'

Now I get the list of courses

edx-dl -u "[email protected]" --list-courses
edx_dl version 0.1.10
Password:
Building initial headers for future requests.
Getting initial CSRF token.
Found CSRF token.
Logging into Open edX site: https://courses.edx.org/login_ajax
Extracting course information from dashboard.
You can access 3 courses
 1 - Data Analysis in Social Science-Assessing Your Knowledge [course-v1:MITx+14.310Fx+3T2019/co]
     https://courses.edx.org/courses/course-v1:MITx+14.310Fx+3T2019/course/
 2 - Data Analysis for Social Scientists [course-v1:MITx+14.310x+2T2019a/co]
     https://courses.edx.org/courses/course-v1:MITx+14.310x+2T2019a/course/
...

Not sure if this a proper fix, though. The program will only download the course surveys

Extracting course information from dashboard.
Downloading Data Analysis for Social Scientists [course-v1:MITx+14.310x+2T2019a/co]
Downloading 2 section(s)
Section  1: Entrance Survey
  Entrance Survey
Section  2: Exit Survey
  Exit Survey

@M-Oliv3
Copy link
Author

M-Oliv3 commented Dec 6, 2019

I tested. Now I'm able to login successfully.
I get the list of courses too, and the download is Ok.

If the Course is only partially downloaded , please see the follow link.
#559 (comment)

Thank you!

@balta2ar
Copy link
Member

balta2ar commented Dec 8, 2019

Released version 0.1.11, give it a try.

@balta2ar balta2ar closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants