Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Python Post Request Help
- Chiroyce
-
1000+ posts
Python Post Request Help
Keep in mind that I already have a valid sessionID
and sadly I get
Then I added
and then i get an error
URL = 'https://scratch.mit.edu/site-api/comments/user/Chiroyce/add/' text = input("Enter Comment") biscuit = {'scratchsessionsid': sessionId+';'} data = {"content":text,"parent_id":"","commentee_id":""} x = requests.post(URL, data=text, cookies=biscuit) sys.exit(x)
and sadly I get
<Response [403]>
Then I added
origin='https://scratch.mit.edu'
URL = 'https://scratch.mit.edu/site-api/comments/user/Chiroyce/add/' text = input("Enter Comment") biscuit = {'scratchsessionsid': sessionId+';'} data = {"content":text,"parent_id":"","commentee_id":""} x = requests.post(URL, data=text, cookies=biscuit, origin='https://scratch.mit.edu') sys.exit(x)
and then i get an error
File "C:\Users\_____\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'origin'
Last edited by Chiroyce (April 26, 2021 11:09:30)
- Maximouse
-
1000+ posts
Python Post Request Help
The session ID should not end with “;”, but I think it should be in quotes.
For origin, use the “headers” parameter:
For origin, use the “headers” parameter:
x = requests.post(URL, data=text, cookies=biscuit, headers={'Origin': 'https://scratch.mit.edu'})
- Chiroyce
-
1000+ posts
Python Post Request Help
No luck, I still get

I also tried this

URL = 'https://scratch.mit.edu/site-api/comments/user/Chiroyce/add/' text = input("Enter Comment") biscuit = {'scratchsessionsid': 'sessionId'} data = {"content":text,"parent_id":"","commentee_id":""} x = requests.post(URL, data=text, cookies=biscuit, headers={'Origin': 'https://scratch.mit.edu'}) sys.exit(x)
I also tried this
URL = 'https://scratch.mit.edu/site-api/comments/user/Chiroyce/add/' text = input("Enter Comment") biscuit = {'scratchsessionsid': sessionId} # no quotes data = {"content":text,"parent_id":"","commentee_id":""} x = requests.post(URL, data=text, cookies=biscuit, headers={'Origin': 'https://scratch.mit.edu'}) sys.exit(x)
- Maximouse
-
1000+ posts
Python Post Request Help
I think it should be No luck, I still getURL = 'https://scratch.mit.edu/site-api/comments/user/Chiroyce/add/' text = input("Enter Comment") biscuit = {'scratchsessionsid': 'sessionId'} data = {"content":text,"parent_id":"","commentee_id":""} x = requests.post(URL, data=text, cookies=biscuit, headers={'Origin': 'https://scratch.mit.edu'}) sys.exit(x)
I also tried thisURL = 'https://scratch.mit.edu/site-api/comments/user/Chiroyce/add/' text = input("Enter Comment") biscuit = {'scratchsessionsid': sessionId} # no quotes data = {"content":text,"parent_id":"","commentee_id":""} x = requests.post(URL, data=text, cookies=biscuit, headers={'Origin': 'https://scratch.mit.edu'}) sys.exit(x)
biscuit = {'scratchsessionsid': f'"{sessionId}"'}
- Chiroyce
-
1000+ posts
Python Post Request Help
No luck, I get a 403 – again I think it should bebiscuit = {'scratchsessionsid': f'"{sessionId}"'}

- Chiroyce
-
1000+ posts
Python Post Request Help
how do i get the CSRF token now ? and where should I add it? I think you need to add the csrf token
- Maximouse
-
1000+ posts
Python Post Request Help
Send a scratchcsrftoken cookie with any value and an X-CSRFToken header with the same value.how do i get the CSRF token now ? and where should I add it? I think you need to add the csrf token
- mybearworld
-
1000+ posts
Python Post Request Help
Are you allowed to set the “Origin” in headers?
- 9gr
-
1000+ posts
Python Post Request Help
1. go into console
2. get the document.cookie value
3. copy it
4. paste it as your cookie value
5. headers as:
should work i think
2. get the document.cookie value
3. copy it
4. paste it as your cookie value
5. headers as:
{ "X-CSRFToken": "a", """replace a with your csrftoken """ "X-Requested-With": "XMLHttpRequest", "origin": "https://scratch.mit.edu/users/Chiroyce" }
Last edited by 9gr (April 28, 2021 17:43:53)
- Maximouse
-
1000+ posts
Python Post Request Help
This is not in a browser, so yes. Are you allowed to set the “Origin” in headers?
- Discussion Forums
- » Advanced Topics
-
» Python Post Request Help