I can’t figure out how to create a game request in python. I am able to get the games list (i.e. the “get” request works to get the list of active games), but trying to do a POST request fails.
Here is (part of) my code: I am calling this class method.
def CreateChallenge(self):
values = {
"game": {
"name": "test",
"rules": "japanese",
"ranked": False,
"handicap": 0,
"time_control_parameters": {
"time_control": "fischer",
"initial_time": 259200,
"max_time": 604800,
"time_increment": 86400
},
"pause_on_weekends": True,
"width": 9,
"height": 9,
"disable_analysis": True
},
"challenger_color": "automatic",
"min_ranking": 0,
"max_ranking": 0
}
headers = {
"Content-Type": "application/json",
"Authorization" : "Bearer " + self.access_token
}
req = requests.post('http://online-go.com/v1/challenges/', data=values, headers=headers)
My reference has been here:
http://docs.ogs.apiary.io/#reference/challenges/challenges-list/create-a-new-open-challenge
but there is no mention of needed authorization in this request. Moreover, the example shows a 200 response code, but when I use the code and run the example in the “console” section of the website I get a 301 error.
Any help will be appreciated. Thank you!
(P.S. On Apiary, the python code has true and false instead of True and False: capitalization is necessary)