• Resolved hubertre

    (@hubertre)


    Hey everyone,

    I have a problem where I can’t get any further.

    I’m trying to update the league table with REST API.
    I use python for that.

    I manage to update data like date or status but it doesn’t work to change the data of the table (data).

    example that work:

    import requests
    import json
    import pprint
    
    username = 'xxx'
    password = 'xxx'
    api_url = "https://www.xxx.xx/wp-json/sportspress/v2/tables/5591"
    headers = {'content-type': 'application/json'}
    
    data = {'status': 'publish'}
    
    response = requests.patch(api_url, auth=(username, password), json=data, headers=headers)
    response.json()
    
    print(response.json())

    example that does not work:

    import requests
    import json
    import pprint
    
    username = 'xxx'
    password = 'xxx'
    api_url = "https://www.xxx.xx/wp-json/sportspress/v2/tables/5591"
    headers = {'content-type': 'application/json'}
    
    data = {'data': {'574': {'p': '14'}}}
    
    response = requests.patch(api_url, auth=(username, password), json=data, headers=headers)
    response.json()
    
    print(response.json())

    In all cases I get the status code 200 as response. I’ve also tried Postman. With the same result.

    I would be happy if you could help me with this. Many thanks and best regards!

    • This topic was modified 1 year, 8 months ago by hubertre.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Roch

    (@rochesterj)

    Hi there!

    Thanks for reaching out.

    League tables are defined by the events. So you’ll probably need to edit the events for that league table (or add new ones) so that the league table loads the correct values.

    Thanks!

    Thread Starter hubertre

    (@hubertre)

    Hi,

    thanks for your answer.
    I was able to solve the problem by uncomment $value = rest_sanitize_array( $value ) in wp-includes/rest-api-php

    Roch

    (@rochesterj)

    I’m glad it’s resolved!

    Let us know if you need anything else.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘League Table update via REST API’ is closed to new replies.