steam
steam copied to clipboard
PlaceBuyOrder and SellItem not working
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!
Have you solved this problem? I still don't understand the magic of its occurrence. It is, then it is not
Usually refreshing the session will work. The cause is unknown.