#Update a Swiss Tournament

8 messages · Page 1 of 1 (latest)

unique minnow
#

Hey,

I have some questions about around: 'Create a new Swiss tournament' and 'Update a Swiss tournament'.

  1. Should I use: ''application/x-www-form-urlencoded' or 'Content-Type: application/json'?
    The API docs mentions: 'application/x-www-form-urlencoded'. But I find it much easier to use the JSON.

  2. Is the 'Update a Swiss tournament' working as intended (or am I a dummy)?
    I am getting Cross origin request forbidden every time.

cURL of 'Create a new Swiss tournament' API (working fine):

--header 'Content-Type: application/json' \
--header 'Authorization: Bearer lip_sometoken' \
--data '{
  "clock": {
    "limit": 300,
    "increment": 3
  },
  "nbRounds": 5
}'```

cURL of 'Update a Swiss tournament' API (not working):

```curl --location 'https://lichess.org/api/swiss/sometournament/edit' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer lip_sometoken \
--data '{
  "clock": {
    "limit": 300,
    "increment": 3
  },
  "nbRounds": 5
}'```

Already thankful for the help.
hard mulch
#

a) --header 'Content-Type: application/json' should be --header 'Accept: application/json'
b) --data argument must be of the form param1=value1&param2=value2

unique minnow
hard mulch
#

Don't know then - maybe it's borked. You could run with curl --verbose to look for logs.

pearl yarrow
#

Indeed, looks borked. Tried with the clock.limit and clock.increment parameters too, which are marked as required in the documenattion - still a no no...
https://lichess.org/api#tag/Swiss-tournaments/operation/apiSwissUpdate

jshell> var updated = client.tournaments().updateSwiss("exR8RhP1", params -> params.clockRapid10m5s().nbRounds(5)).get();
Aug 25, 2023 5:57:37 PM chariot.internal.InternalClient request
INFO: ### Request: POST http://localhost:9663/api/swiss/exR8RhP1/edit
Headers:
accept: application/json
authorization: Bearer ***
content-type: application/x-www-form-urlencoded
user-agent: Java/20.0.2 chariot/0.0.1-SNAPSHOT
Body:
clock.limit=600&clock.increment=5&nbRounds=5
Aug 25, 2023 5:57:37 PM chariot.internal.InternalClient request
INFO: ### Response: (POST http://localhost:9663/api/swiss/exR8RhP1/edit) 403
Body:
Cross origin request forbidden
Headers:
[access-control-allow-headers] [[Origin, Authorization, If-Modified-Since, Cache-Control, Content-Type]]
[access-control-allow-methods] [[OPTIONS, GET, POST, PUT, DELETE]]
[access-control-allow-origin] [[*]]
[content-length] [[30]]
[content-type] [[text/plain; charset=utf-8]]
[date] [[Fri, 25 Aug 2023 15:57:37 GMT]]
[vary] [[Origin]]
pearl yarrow
unique minnow
#

Will do. The API documentation is indeed flawless.