Open tryenc opened 8 years ago
According to their API documentation, the key for the actual file should be file
and not asset_data
: https://developers.soundcloud.com/docs/api/guide#uploading
Is there a reason you're using asset_data
?
Hey Jake,
Thanks for getting back so fast. I was using 'asset_data' because that's what the API Reference says to use for a request to '/tracks'. The 'asset_data' property is at the very bottom of the '/tracks' section. Regardless, I tried issuing the same post using 'file' in place of 'asset_data' and I got the same error.
Thanks again for the fast response. I'm really looking forward to getting this solved.
Ah, okay. How are you retrieving your access_token
?
Utilizing the JavaScript SDK inside of an Angular controller. The SDK is requested in a script tag in the HTML. If I upload with the SDK from the front-end it's working.
app.controller('SoundcloudController', ['$scope', 'SoundcloudService', function($scope, SoundcloudService){
SC.initialize({
client_id: 'somefakecilentid',
redirect_uri: 'http://localhost:1337/callback.html',
display: 'popup'
});
$scope.song = {};
$scope.upload = function(){
var fd = new FormData();
fd.append('file', $scope.song.file);
fd.append('title', $scope.song.title);
SC.connect({
scope: 'non-expiring',
response_type: 'token'
})
//================ UPLOAD FROM FRONT-END ================
// .then(function(){
// return SC.upload({
// file: $scope.song.file,
// title: $scope.song.title
// })
// })
// .then(function(track){
// console.log("track", track);
// })
//========== UPLOAD FROM BACK-END WITH SERVICE ==========
.then(function(res){
console.log("res.oauth_token", res.oauth_token);
return fd.append('accessToken', res.oauth_token);
})
.then(function(){
return SoundcloudService.uploadFile(fd);
})
.then(function(res){
console.log("res", res);
})
};
}]);
Hey Guys!
I'm getting the same error and I'm following the same method which Tryenc has used.. is there any resolution for this?
Thank you!
I'm running into something similar too, I'm using the connect screen authentication to get a token but any subsequent requests return a 401.
I'm getting a
401 - Unauthorized
on POST request to the '/tracks' route. I'm trying to upload a track to my Soundcloud profile. Any idea why this wouldn't be working? Thanks so much in advance!