当 PUT 到 Soundcloud API 上的播放列表时,播放列表实际上并没有更新?

When PUTting to a playlist on Soundcloud's API, the playlist doesn't actually get updated?

当我尝试通过 API 使用数据结构 {"tracks": [{"id": 12345}, {"id": 45678}]} HTTP PUT SoundCloud 播放列表时,播放列表没有得到更新。 API returns 播放列表中内容的 200 响应,完全忽略修改。

我认为可能是错误的

  1. SoundCloud API 不接受该数据格式

  2. 授权无效,即使它返回 200

代码:

import requests
playlist_url = 'https://api.soundcloud.com/playlists/XXXXX?client_id=XXXXX'
like_url = 'https://api.soundcloud.com/users/XXXXX/favorites?client_id=XXXXX'
likes = requests.get(like_url)
likes_json = likes.json()

# oauth2_token = requests.post('https://api.soundcloud.com/oauth2/token', data=opts).json()
oauth2_token = 'XXXXX'
playlist = {'tracks': []}
for like in likes_json[::-1]:
    track_id = like['id']
    playlist['tracks'].append({'id': track_id})

resp = requests.put('https://api.soundcloud.com/playlists/XXXXX', json=playlist, params={
                                                                                'oauth_token': oauth2_token,
                                                                                'client_id': 'XXXXX',
                                                                                'client_secret': 'XXXXX'
                                                                                })

原来我只是发送了错误的数据结构。应该是 {'playlist': {'tracks': [{'id': 1234}, {'id': 4567}]}}.