Reputation: 3618
Having some problems uploading a track using the soundcloud python library to interact with the Soundcloud api.
Error Log:
Traceback (most recent call last):
File "uploadToSoundcloud.py", line 25, in <module>
'asset_data': open('/home/jhvisser/Music/driveAt5_'+now.strftime("%y%m%d")+'.mp3', 'rb')
File "/usr/local/lib/python2.7/dist-packages/soundcloud/client.py", line 130, in _request
return wrapped_resource(make_request(method, url, kwargs))
File "/usr/local/lib/python2.7/dist-packages/soundcloud/request.py", line 134, in make_request
result.raise_for_status()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 722, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.422 Client Error: Unknown Error
Code causing error. Line 25 refers to the assest_data line.
#Upload driveAtFive to SoundCloud
driveAtFive = client.post('/tracks', driveAtFive={
'title': 'Drive at 5 - ' + now.strftime("%Y-%m-%d"),
'sharing': 'public',
'asset_data': open('/home/jhvisser/Music/driveAt5_'+now.strftime("%y%m%d")+'.mp3', 'rb')
})
Upvotes: 0
Views: 1064
Reputation: 4117
You need to pass the track
keyword argument. Here you've named it driveAtFive
which is incorrect. Change the code example to this:
driveAtFive = client.post('/tracks', track={
'title': 'Drive at 5 - ' + now.strftime("%Y-%m-%d"),
'sharing': 'public',
'asset_data': open('/home/jhvisser/Music/driveAt5_'+now.strftime("%y%m%d")+'.mp3', 'rb')
})
Let me know if that helps.
Upvotes: 3