Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlaceBuyOrder and SellItem not working #12

Open
tikz opened this issue Feb 26, 2019 · 2 comments
Open

PlaceBuyOrder and SellItem not working #12

tikz opened this issue Feb 26, 2019 · 2 comments

Comments

@tikz
Copy link

tikz commented Feb 26, 2019

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!

@MakcStudio
Copy link

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

@asamy
Copy link
Contributor

asamy commented Sep 2, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants