I'm trying to upload a sound to soundcloud using WebService::Soundcloud
. I've so far been able to make a couple of GET/POST requests following the examples provided by the WebService::Soundcloud
documentation.
However, I can't find a decent example anywhere on how to do an upload while passing the required parameters i.e. track, and within it, asset_data, title e.t.c. I'm wondering if I should be sending out a multipart message.
Any examples will be appreciated!
Also, here's what I have tried so far: After authenticating and getting a valid WebService::Soundcloud
instance.
GET my $response = $scloud->get( '/me/tracks' );
PUT my $response = $scloud->put( '/me/tracks/91576621', JSON::to_json({track=>{title=>"My test title",description=>"My test description"}}) );
POST my $file = '/home/ski/track1.mp3';
my $asset_data = File::Slurp::read_file( $file, binmode => ':raw' );
my $response = $scloud->post('/me/tracks', '{"track":{"title":"My test title","asset_data":"'.$asset_data.'"}}' );
This fails with "Request entity contains invalid byte sequence. Please transmit valid UTF-8"
WebService::Soundcloud
instance. GETmy $response = $scloud->get( '/me/tracks' );
PUTmy $response = $scloud->put( '/me/tracks/91576621', JSON::to_json({track=>{title=>"My test title",description=>"My test description"}}) );
POSTmy $file = '/home/ski/track1.mp3'; my $asset_data = File::Slurp::read_file( $file, binmode => ':raw' ); my $response = $scloud->post('/me/tracks', '{"track":{"title":"My test title","asset_data":"'.$asset_data.'"}}' );
This fails with "Request entity contains invalid byte sequence. Please transmit valid UTF-8" – CoprolaliaWebService::Soundcloud
norJSON::to_json
- but could it be that the problem is in the syntax for theJSON::to_json
. Have you tried usingencode_json()
instead, as does theWebService::Soundcloud
documentation for PUT requests? – Hoke$response->content()
. And i did tryencode_json()
as well as just writing the json string myself. Thats probably not the issue since thePUT
example above works just fine withJSON::to_json
. – Coprolalia