escept Posted August 10, 2017 Share Posted August 10, 2017 Hello, For me the Create listings API is not informative as i'm really new to JSON and other kinds of stuff. Sending a JSON post request to create a new listing does not seem to work. My Code: {"token":"xxxxxxxxxxxxxxxxxxxxxxxxx","listings":["intent":"1","id":"30310","offers":"1","buyout":"1","details":"test","currencies":["metal":10]]}", The link: "https://backpack.tf/api/classifieds/list/v1" Link to comment Share on other sites More sharing options...
Julia Posted August 10, 2017 Share Posted August 10, 2017 The listing JSON should be formatted like this: { "listings":[ { "intent":1, "id":5986406778, "currencies":{ "keys":8 }, "details":"With Headshot Kills", "buyout":1, "offers":1, "promoted":0 } ] } Your JSON is not properly formatted (and isn't valid JSON either). "listings" is an array of objects, and "currencies" is an object ("metal" and/or "keys"). Alberny 1 Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Oh, thanks for the help! Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Now using that code i get a 400 bad request error. I'm trying to post the json you provided, just changed the item id to something i actually have. I'm sending it to this url: "https://backpack.tf/api/classifieds/list/v1?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxx" Link to comment Share on other sites More sharing options...
Axle Change Posted August 10, 2017 Share Posted August 10, 2017 30 minutes ago, escept said: -snip- Edit your post please, you included your api token on the url. Error 400 probably means you probably didn't set your headers or sent an invalid object. You should probably send it as a string because it makes life much easier. Set headers to 'content-type': 'application/json' Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 As i said, i'm pretty new to json, and programming altogether, i don't really know what you meant by that. I'm trying to make this in vb.net and my code is Dim jsonszar As String jsonszar = " { ""content-type"":""application/json"" ""token"":""-"" ""listings"":[ { ""intent"":1, ""id"":30797, ""currencies"":{ ""metal"":1 }, ""details"":""test"", ""buyout"":1, ""offers"":1, ""promoted"":0 } ] } " Dim myrequest As HttpWebRequest = postjson(jsonszar, "https://backpack.tf/api/classifieds/list/v1") I'm sorry for everyone who i'm nerve-racking for.. Link to comment Share on other sites More sharing options...
pewpewAttack Posted August 10, 2017 Share Posted August 10, 2017 I think ur using the wrong id. ur id is only 5 in length in the example Julia gave its 10. Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Where should i get the id from then? Link to comment Share on other sites More sharing options...
manic Posted August 10, 2017 Share Posted August 10, 2017 3 minutes ago, escept said: Where should i get the id from then? You should use the 3rd party access token: https://backpack.tf/settings##advanced . And you posted your key again. Edit: rip, read token not id. The id is the current id which you can get from using the steam inventory API. Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Not that, the item id. Oh and sorry i did not notice that one. Link to comment Share on other sites More sharing options...
pewpewAttack Posted August 10, 2017 Share Posted August 10, 2017 you would need to use the steam inventory api or if you just want to test it out now https://backpack.tf/item/4083557913, For a test , this item has an id of 5622776387 you can try that for now.(btw this is ur item that u own) Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 still not working... i think now it's the code itself that has problems.. Link to comment Share on other sites More sharing options...
Julia Posted August 10, 2017 Share Posted August 10, 2017 2 hours ago, escept said: As i said, i'm pretty new to json, and programming altogether, i don't really know what you meant by that. I'm trying to make this in vb.net and my code is Dim jsonszar As String jsonszar = " { ""content-type"":""application/json"" ""token"":""-"" ""listings"":[ { ""intent"":1, ""id"":30797, ""currencies"":{ ""metal"":1 }, ""details"":""test"", ""buyout"":1, ""offers"":1, ""promoted"":0 } ] } " Dim myrequest As HttpWebRequest = postjson(jsonszar, "https://backpack.tf/api/classifieds/list/v1") I'm sorry for everyone who i'm nerve-racking for.. You don't add the "content-type" in the POST data, it belongs in the request headers. You should have a basic understanding of how web requests work. The request method should be POST and any JSON should be the "form" of your request. You should look up some examples of a properly formatted POST request. Also I noticed recently that backpack.tf gives errors if you try to view any page without a user-agent in the request. If there is something wrong with your post data backpack.tf will usually return JSON that includes an error message. If there is a problem with your request you won't get a proper response. If your JSON is not properly formatted it might cause an error too. So in your request headers you should have something like: { "Content-Type":"application/json", "User-Agent":"someuseragent" } Setting the content-type to application/json tells the server that you're sending JSON. 1 hour ago, pewpewAttack said: I think ur using the wrong id. ur id is only 5 in length in the example Julia gave its 10. The ID is the ID of the item you want to sell. Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 - Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Okay so now i got the JSON itself, but I tried like 10 examples of POSTing JSON with vb.net, But none of them worked. Link to comment Share on other sites More sharing options...
manic Posted August 10, 2017 Share Posted August 10, 2017 50 minutes ago, escept said: Okay so now i got the JSON itself, but I tried like 10 examples of POSTing JSON with vb.net, But none of them worked. Does this way of doing it work with the other APIs? (mainly the GET ones) Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Actually i only tried the POST ones. Link to comment Share on other sites More sharing options...
manic Posted August 10, 2017 Share Posted August 10, 2017 1 minute ago, escept said: Actually i only tried the POST ones. Try that, they're easier. You can see if you've messed up the syntax and response handing or if it's something else. Link to comment Share on other sites More sharing options...
escept Posted August 10, 2017 Author Share Posted August 10, 2017 Actually i have been trying with get requests too but i still can't parse the output... trying for 2 hours now.. Why is just getting a value so hard? Link to comment Share on other sites More sharing options...
escept Posted August 11, 2017 Author Share Posted August 11, 2017 Well i'm making progress, sending to https://backpack.tf/api/classifieds/list/v1 JSON: {'token': 'hidden', 'listings': [{'intent': 1, 'id': 5622776387, 'currencies': { 'metal':1 }, 'details': 'test', 'buyout': 1, 'offers': 1, 'promoted': 0 }]}} Headers: 'User-Agent': 'Super Agent/0.0.1', 'Content-Type': 'application/json' And in response i'm getting 500: Internal Server Error And by the looks of it the website code itself. Link to comment Share on other sites More sharing options...
Axle Change Posted August 11, 2017 Share Posted August 11, 2017 9 hours ago, escept said: -snip- Can confirm 500 error. Seems to be an error with the site as far as I can tell, only thrown with sell =1. Link to comment Share on other sites More sharing options...
escept Posted August 11, 2017 Author Share Posted August 11, 2017 oh ok, btw i tried NodeJS instead of vb.net as it looked impossible to do post requests Link to comment Share on other sites More sharing options...
escept Posted August 12, 2017 Author Share Posted August 12, 2017 with the buy request i get a response: {"listings":{"Showstopper":{"error":7,"used":0,"cap":0}}} Any item that i try to create an order for returns this... Link to comment Share on other sites More sharing options...
manic Posted August 12, 2017 Share Posted August 12, 2017 5 hours ago, escept said: with the buy request i get a response: {"listings":{"Showstopper":{"error":7,"used":0,"cap":0}}} Any item that i try to create an order for returns this... You need to use your third party access token not your API key. (backpack - settings - advanced) Link to comment Share on other sites More sharing options...
pewpewAttack Posted August 12, 2017 Share Posted August 12, 2017 6 hours ago, escept said: with the buy request i get a response: {"listings":{"Showstopper":{"error":7,"used":0,"cap":0}}} Any item that i try to create an order for returns this... It literally tells you in the documentation what the problem is. You have an error code 7 which if you look at the list of error codes tells you this, enum { OK = 0; ItemNotInInventory = 1; InvalidItem = 2; ItemNotListable = 3; ItemNotTradable = 4; MarketplaceItemNotPriced = 5; RelistTimeout = 6; ListingCapExceeded = 7; CurrenciesNotSpecified = 8; CyclicCurrency = 9; PriceNotSpecified = 10; UnknownIntent = 11; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now