speedruncomorg / api

REST API Documentation for speedrun.com
346 stars 36 forks source link

`POST /runs` returns status 400 #156

Closed Bluestonex63 closed 1 year ago

Bluestonex63 commented 1 year ago

Im trying to post a run to laser arena wth python, but it always returns the following response: {'status': 400, 'message': 'The payload does not contain a "run" element at its root.', 'links': [{'rel': 'support', 'uri': 'irc://speedrunslive.com#speedrun.com'}, {'rel': 'report-issues', 'uri': 'https://github.com/speedruncom/api/issues'}]}

My code looks something like this: requests.post('https://www.speedrun.com/api/v1/runs', headers={ "X-API-Key": "key" }, json=""" { "run": { "category": "7dg13gxd", "level": null, "date": "2022-9-2", "region": null, "platform": "8gej2n93", "verified": false, "times": { "realtime": 7871231, }, "players": [ {"rel": "user", "id": "x3qmp56j"} ], "emulated": false, "video": "https://www.youtube.com/watch?v=thisisatest", "comment": "test", "splitsio": "", "variables": { "onvvee7n": { "type": "pre-defined", "value": "4qykw331" }, "ylp6oo6n": { "type": "pre-defined", "value": "zqozvdgl" }, "0nwp4408": { "type": "pre-defined", "value": "gq7yxenq" }, "wl3955vl": { "type": "pre-defined", "value": "mlngomn1" }, "2lg500e8": { "type": "pre-defined", "value": "z190py41" } } } }""")

I really dont know why this is happening, any guesses would help

Bluestonex63 commented 1 year ago

Solved, I need to pass out an actual dictionary and not a string.