What Comes Around Posted December 23, 2020 Report Posted December 23, 2020 (edited) Good day/night, I'd like to ask what I am doing wrong? Here is what I have: client.logOn(loginOptions); client.on('loggedOn', () => { console.log('logged on'); client.setPersona(1); }); client.on('webSession', async (sid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); community.startConfirmationChecker(20000, config.identity_secret); let item = await getItem() var requestoptions = { form: { sessionid: community.getSessionID(), appid: item.appid, contextid: item.contextid, amount: 1, price: 10 }, headers: { 'Origin': 'http://steamcommunity.com', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Referer': 'http://steamcommunity.com/my/inventory/', 'Connection': 'keep-alive', 'Cookie': cookies, 'Host': 'steamcommunity.com', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5' }, json: true } console.log(requestoptions) community.httpRequestPost('https://steamcommunity.com/market/sellitem/', {requestoptions}, (err, response, json) => { if (err) { console.log(err.toString()); return; } console.log(json) }, "steamcommunity") }) const getItem = () => { return new Promise((resolve, reject) => { manager.getInventoryContents(730, 2, true, (err, inventory) => { if (err) { reject(err); } else { resolve(inventory[0]); } }) }) } I keep getting: Error: HTTP error 400 Any advice? Edited April 13, 2021 by What Comes Around Quote
Dr. McKay Posted December 24, 2020 Report Posted December 24, 2020 Get rid of the curly braces around requestoptions. And also quit using the confirmation checker as it's been deprecated for years. What Comes Around 1 Quote
What Comes Around Posted December 24, 2020 Author Report Posted December 24, 2020 15 hours ago, Dr. McKay said: Get rid of the curly braces around requestoptions. And also quit using the confirmation checker as it's been deprecated for years. Oops, my bad. It was old code that I copy pasted. I stopped using confirmation checker Also, still getting 400, what could I be doing wrong? Could it be the user agent? I've also tried sending the request to the http address instead, but I got either Malformed Request (without curly braces around requestoptions) or a redirect (with curly braces around requestoptions). Quote
What Comes Around Posted December 25, 2020 Author Report Posted December 25, 2020 19 hours ago, What Comes Around said: Oops, my bad. It was old code that I copy pasted. I stopped using confirmation checker Also, still getting 400, what could I be doing wrong? Could it be the user agent? I've also tried sending the request to the http address instead, but I got either Malformed Request (without curly braces around requestoptions) or a redirect (with curly braces around requestoptions). Sorry, the redirect was the result of me trying http not https, however steam redirects http requests to https. Had nothing to do with curly braces. Also I read from a similar thread : https://dev.doctormckay.com/topic/1495-automatically-selling-steam-items-error-400/?tab=comments#elControls_4826:~:text=When you're doing things on the,any of those other headers either. that the headers shouldn't be entered manually. Is there a way for me to extract that data from the client by any chance? Quote
Dr. McKay Posted December 27, 2020 Report Posted December 27, 2020 You need to specify Origin and Referer manually, but all the other headers you're specifying should be left out as they're HTTP protocol-level headers that request will set on its own. What Comes Around 1 Quote
What Comes Around Posted December 30, 2020 Author Report Posted December 30, 2020 On 12/27/2020 at 9:50 PM, Dr. McKay said: You need to specify Origin and Referer manually, but all the other headers you're specifying should be left out as they're HTTP protocol-level headers that request will set on its own. Thanks! Here is what I have right now: const SteamUser = require('steam-user'); const SteamTotp = require('steam-totp'); const config = require('./config'); const SteamCommunity = require('steamcommunity'); const TradeOfferManager = require('steam-tradeoffer-manager'); const client = new SteamUser(); const community = new SteamCommunity(); const manager = new TradeOfferManager({ steam: client, community: community, language: 'en' }) const loginOptions = { accountName: config.username, password: config.password, twoFactorCode: SteamTotp.generateAuthCode(config.shared_secret) } client.logOn(loginOptions); client.on('loggedOn', () => { console.log('logged on'); client.setPersona(1); }); client.on('webSession', async (sid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); let item = await getItem() var requestoptions = { form: { sessionid: community.getSessionID(), appid: item.appid, assetid: item.assetid, contextid: item.contextid, amount: 1, price: 10 }, headers: { 'Origin': 'https://steamcommunity.com', 'Referer': 'https://steamcommunity.com/my/inventory/', 'Cookie': cookies, 'Host': 'steamcommunity.com', }, json: true } console.log(requestoptions) community.httpRequestPost('https://steamcommunity.com/market/sellitem/', requestoptions, (err, response, json) => { if (err) { console.log(err.toString()); return; } // console.log(json) console.log(response) }, "steamcommunity") }) const getItem = () => { return new Promise((resolve, reject) => { manager.getInventoryContents(730, 2, true, (err, inventory) => { if (err) { reject(err); } else { resolve(inventory[0]); } }) }) } I've added the assetid because I found that steam uses that on their website for market sell requests. The headers that are set by HTTP protocol have been removed. I am still getting the 400 error. I am thinking I should maybe use the steam client in a sandbox and api call log to find out exactly what I am missing. Or at least I would be able to slowly remove unnecessary fields until I have something basic I can use without getting 400 statuses. So far I have gotten sell orders working on chrome using puppeteer and just using cors mode, but getting inventory information and other account details with puppeteer would be a real hassle when as great of a library as yours exists. So this is where I am, I will try to get api logging working and hopefully find out what I am missing. Or of course if you see any mistakes please let me know. Quote
Dr. McKay Posted December 31, 2020 Report Posted December 31, 2020 Only set Origin and Referer. Do not set Host or Cookie. What Comes Around 1 Quote
What Comes Around Posted January 1, 2021 Author Report Posted January 1, 2021 On 12/31/2020 at 9:57 AM, Dr. McKay said: Only set Origin and Referer. Do not set Host or Cookie. OOPS, that makes sense, because I have already set cookies for community. It is now working. Thank you very much! I would also like to ask if using this extensively could be a ban-able offence on steam? And thanks again for your help, really appreciate it! I also really appreciate all of your work in general! Quote
Dr. McKay Posted January 4, 2021 Report Posted January 4, 2021 Unless you're doing something shady, I wouldn't expect Valve to pay any mind to you. What Comes Around 1 Quote
What Comes Around Posted January 4, 2021 Author Report Posted January 4, 2021 (edited) 4 hours ago, Dr. McKay said: Unless you're doing something shady, I wouldn't expect Valve to pay any mind to you. Thanks for clarifying, guess it applies to all kinds of botting activity Edited January 4, 2021 by What Comes Around 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.