3070

Soundcloud API - Adding/Removing Songs from Groups - 404 Error

Question:

I have been trying to use the Soundcloud API to add and remove songs from groups. I am using the soundcloud-python wrapper to enable me to do this easily.

I have got both Auth flows working correctly (either using OAuth2 or using user credentials directly), and I can use the python client to grab information about the logged in user etc. by performing calls as follows:

print client.get('/me').username

This indicates to me that I have correctly passed authorisation, and as I say, I have got this working via both methods.

My problem is when I try to make the following request which is provided as an example to add/remove songs from groups, I will always get a 404 error, whether or not the track already exists in the group (from the example off the Soundcloud API docs, under "Contributing Sounds to a Group"):

# contribute track to group group = client.put('/groups/%d/contributions/%d' % (group.id, track.id))

If I perform any function on the /groups/{group-id}/contributions/{track-id} via the client object, I will always get a 404 error. If I am not authenticated I will get a 401 error. I have made 100% sure that I have used working group_id/track_id combinations by testing them through the API console, and hard-coding values where necessary to prove the operation.

This is what confuses me - if I use the same form of URI which failed with the python wrapper in the API Console (on the Soundcloud API website), and I am authenticated through OAuth, then the GET/PUT and DELETE all behave as expected on the same group_id's and track_id's which fail through the soundcloud-python wrapper.

Has anyone else had any issues with this? Have they got this working?

Many thanks in advance for any help!

Answer1:

The 404 error suggest that you are not authenticated. If that isn't the problem then, <a href="http://developers.soundcloud.com/docs/api/guide#uploading" rel="nofollow">http://developers.soundcloud.com/docs/api/guide#uploading</a> says (in "Contributing a Sound to a Group"):

... Similarly, you can also remove contributions. (python example)

import soundcloud # create a client object with access token client = soundcloud.Client(access_token='YOUR_ACCESS_TOKEN') # delete track id 59 from group id 123 client.delete('/groups/123/contributions/59')

Answer2:

<h2>Update</h2>

The pull request I link to below was accepted and merged into the API wrapper.

Just grab the updated source from Github, and this should be fixed.

<em>p.s. Sorry for the late update.</em>

<hr />

The /contributions endpoint is buggy - see <a href="https://github.com/soundcloud/soundcloud-python/issues/21" rel="nofollow">this github issue</a>.

I've managed to hack the API to make this work until the bug is fixed on SoundCloud's side. Make the following amendments to the <kbd>client.py</kbd> file:

def _resolve_resource_name(self, name): [...] name = name.rstrip('/').lstrip('/') if name[-13:] == 'contributions': return '%s%s/%s' % (self.scheme, self.host, name) return '%s%s/%s.json' % (self.scheme, self.host, name)

Or see <a href="https://github.com/soundcloud/soundcloud-python/pull/28" rel="nofollow">this pull request</a>.

Recommend

  • Batch File try catch
  • How to add a d3js graph in slideshow instead of body?
  • Message: stale element reference: element is not attached to the page document in Python
  • m2crypto: python 2.7 compatibility and which version of OpenSSL to use?
  • What is the proper way to handle menu items in a master/detail flow?
  • Java - add a button in a cell in a Jtable
  • How to compute daily average for 15 years?
  • How does Chrome get device orientation information?
  • ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking
  • Change color of row programmatically in WatchKit
  • Stitching 2 images (OpenCV)
  • How can I see a list of all files that are different between two Hg repositories?
  • Receive mouse move even cursor is outside control
  • Request response issues in biztalk
  • Possible to get mouse events fired when cursor is outside page?
  • Overlapping controls in Windows XP
  • Unable to get column index with table.getColumn method using custom table Model
  • Transactional Create with Validation in ServiceStack Redis Client
  • Hardware Accelerated Image Scaling in windows using C++
  • Java: can you cast Class into a specific interface?
  • Read text file and split every line in MSBuild
  • AES padding and writing the ciphertext to a disk file
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Build own AppleScript numerical error handling
  • Websockets service method fails during R startup
  • Google cloud sdk not working when python points python3
  • Is there a mandatory requirement to switch app.yaml?
  • How to delete a row from a dynamic generate table using jquery?
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Suggestions to manage Login/Logout transitions
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • embed rChart in Markdown
  • How to stop GridView from loading again when I press back button?
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass