Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » How to change title with API?
- god286
- Scratcher
1000+ posts
How to change title with API?
I have code here:
It gives 403 Unauthorised though?
I took code from scratchclient
async setTitle(value: string) { const setFetch = await fetch(`https://api.scratch.mit.edu/projects/${this.id}`, { method: "PUT", body: JSON.stringify({ title: value }), headers: { "x-csrftoken": this.session.csrfToken, "X-Token": this.session.token, "x-requested-with": "XMLHttpRequest", Cookie: "scratchcsrftoken=" + this.session.csrfToken + ";scratchlanguage=en;scratchsessionsid=" + this.session.token + ";", referer: `https://scratch.mit.edu/projects/${this.id}/`, "User-Agent": UserAgent, accept: "application/json", "Content-Type": "application/json" } }) if (!setFetch.ok) { throw new Error(`Error in setting title. ${await setFetch.text()}`) } }
I took code from scratchclient
Last edited by god286 (Jan. 25, 2022 04:21:34)
Here are some of my followers!
I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
- -EmeraldThunder-
- Scratcher
1000+ posts
How to change title with API?
Are you sure your code to log you in is correct?
Nothing here.
- god286
- Scratcher
1000+ posts
How to change title with API?
yes I am sure, I got a CSRF Token and Token back, but I checked network logs, it doesn't seem to need CSRF token, and X-Token is something different? Where do I get that X-Token?? Are you sure your code to log you in is correct?
Last edited by god286 (Jan. 25, 2022 06:35:31)
Here are some of my followers!
I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
- god286
- Scratcher
1000+ posts
How to change title with API?
OK can someone please explain to me where that X-Token comes from in the request to https://api.scratch.mit.edu/projects/ID ??? I have no idea…
Here are some of my followers!
I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
- Maximouse
- Scratcher
1000+ posts
How to change title with API?
https://api.scratch.mit.edu/projects/ID ??? I have no idea…You need to request OK can someone please explain to me where that X-Token comes from in the request to https://scratch.mit.edu/session/ with the scratchsessionid cookie to get the token.
- god286
- Scratcher
1000+ posts
How to change title with API?
Thank you so much!!https://api.scratch.mit.edu/projects/ID ??? I have no idea…You need to request OK can someone please explain to me where that X-Token comes from in the request to https://scratch.mit.edu/session/ with the scratchsessionid cookie to get the token.
Here are some of my followers!
I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
- Discussion Forums
- » Advanced Topics
- » How to change title with API?