SteamUs1 Posted Sunday at 06:21 PM Report Posted Sunday at 06:21 PM (edited) When I try to sell an item on the community market with Typescript, I always get a 400 although it totaly works on python. This is my Python code: session = requests.Session() cookies = { "sessionid": "XXX", "steamLoginSecure": "X%7C%XX.X.X", } session.cookies.update(cookies) def sellSteamMarketItem(cookie): url = "https://steamcommunity.com/market/sellitem/" HEADERS = { "Referer": "https://steamcommunity.com/profiles/XXXXXX/inventory" } session_body = session.post("https://steamcommunity.com/market/sellitem/", data={ "sessionid": "XXXXX", "appid": "730", # App-ID (z. B. CS:GO) "contextid": "2", # Kontext-ID (Inventar) "assetid": "XXXX", # Artikel-ID "amount": "1", # Anzahl "price": "149999" }, headers=HEADERS) if session_body.status_code != 200: print("Error, Statuscode: ", session_body.status_code) And this is my Typescript code: create(assetId: number, price: number) { let url: string = "https://steamcommunity.com/market/sellitem/"; const data = { sessionid: this.session.sessionid, appid: "730", contextid: "2", assetid: assetId.toString(), amount: "1", price: price.toString(), }; const referer = "https://steamcommunity.com/profiles/" + this.session.client.steamID.getSteamID64() + "/inventory"; const respone = this.session.steamAPI.httpPost(url, data, referer); console.log(respone); //this.session.community.acceptConfirmationForObject(this.session.identitySecret, respone["listingid"], ) } async sendRequest(url, method, params, referer, repeated=false) { const headers = { "Cookie": this.session.cookies, "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", "Accept": "application/json, text/plain, */*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive", "Referer": referer }; this.response = await axios.post(url, params, { headers: headers }); } Here some Sequences from the Axois Request: { "headers": { "Accept": "application/json, text/plain, */*", "Content-Type": "application/json", "Cookie": "sessionid=XX; steamLoginSecure=XX;", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive", "Referer": "https://steamcommunity.com/profiles/XX/inventory", "Content-Length": "123" }, "method": "post", "url": "https://steamcommunity.com/market/sellitem/", "data": { "sessionid": "XX", "appid": "730", "contextid": "2", "assetid": "XX", "amount": "1", "price": "14555" } } { "data": { "success": false, "message": "Session mismatch" }, "status": 400 } Has anyone an idea, why this occurs? Edited Sunday at 06:22 PM by SteamUs1 Quote
SteamUs1 Posted Tuesday at 08:17 AM Author Report Posted Tuesday at 08:17 AM I found the issue. Its in the Content Type, in Python its "application/x-www-form-urlencoded" and in TS its "application/json". To get the same Type in Python you simply need to format the params (body) right. For example: const data = new URLSearchParams(); data.append('sessionid', sessionid); data.append('appid', '730'); data.append('contextid', '2'); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.