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


when try http put soundcloud playlist through api, data structure: {"tracks": [{"id": 12345}, {"id": 45678}]}, playlist doesn't updated. api returns 200 response in playlist, ignoring modifications.

what think might wrong

  1. the soundcloud api doesn't accept format of data

  2. somehow authorization invalid, though it's returning 200

the code:

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': []} 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'                                                                                 }) 

it turns out sending wrong data structure. should have been {'playlist': {'tracks': [{'id': 1234}, {'id': 4567}]}}.

https://stackoverflow.com/a/28847716/2350164


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -