steam icon indicating copy to clipboard operation
steam copied to clipboard

PlaceBuyOrder and SellItem not working

Open tikz opened this issue 6 years ago • 2 comments

Steam's endpoint to sell an item nowadays seems to require sending the user's inventory URL in the referer, otherwise it returns a HTTP 400 error.

I had to modify the SellItem function locally with the following:

func (session *Session) SellItem(item *InventoryItem, amount, price uint64) (*MarketSellResponse, error) {
	req, err := http.NewRequest(
		http.MethodPost,
		"https://steamcommunity.com/market/sellitem/",
		strings.NewReader(url.Values{
			"amount":    {strconv.FormatUint(amount, 10)},
			"appid":     {strconv.FormatUint(uint64(item.AppID), 10)},
			"assetid":   {strconv.FormatUint(item.AssetID, 10)},
			"contextid": {strconv.FormatUint(item.ContextID, 10)},
			"price":     {strconv.FormatUint(price, 10)},
			"sessionid": {session.sessionID},
		}.Encode()),
	)
	if err != nil {
		return nil, err
	}

	profileURL, err := session.GetProfileURL()
	if err != nil {
		return nil, err
	}

	req.Header.Add(
		"Referer",
		profileURL+"inventory/",
	)

	resp, err := session.client.Do(req)

	// (etc...)
}

Also PlaceBuyOrder isn't working, the response is always: &{ErrCode:107 ErrMsg:Sorry! We had trouble hearing back from the Steam servers about your order. Double check whether or not your order has actually been created or filled. If not, then please try again later. OrderID:0}

I tried to compare the headers, params and cookies with an actual browser request, but in this case I couldn't find anything missing or what is causing it. Any ideas?

BTW love this library, great work!

tikz avatar Feb 26 '19 23:02 tikz

Have you solved this problem? I still don't understand the magic of its occurrence. It is, then it is not

MakcStudio avatar Sep 01 '21 17:09 MakcStudio

Usually refreshing the session will work. The cause is unknown.

asamy avatar Sep 02 '21 06:09 asamy