Skip to content

PlaceBuyOrder and SellItem not working #12

@tikz

Description

@tikz

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions