When creating a track the asset_data is required. This can only be
sent using multipart/form-data. Also the track requires an actual
audio file to successfully create a track. So this is most probably
the source of your error.
If you would have problems with the signing of request you would get
401 Unauthorized errors.
Happy coding!
Cheers,
Hannes
--
Hannes Tydén
Developer, SoundCloud
Mail: han...@soundcloud.com
Skype: hannestyden
Phone: +49 157 7471 6101
Fax: +49 30 8187 8724
Auguststrasse 5a, 101 17, Berlin, DE
What is SoundCloud?
http://soundcloud.com/tour
When creating a track the asset_data is required. This can only be
sent using multipart/form-data. Also the track requires an actual
audio file to successfully create a track. So this is most probably
the source of your error.
If you would have problems with the signing of request you would get
401 Unauthorized errors.
Happy coding!
The parts of the data you sent looks good, but it's hard to say since
the context is important.
>
> Signature Base String:
>
> POST&http%3A%2F%2Fapi.soundcloud.com%2Ftracks&oauth_consumer_key%3DTU7rx9XbIK0bAoB1Bgqw%26oauth_nonce%3Di4ug2df2b1b307e11943%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1255535658%26oauth_token%3Dv4kJxpkzlmrlKjfY6NJjkA%26oauth_version%3D1.0%26track%255Btitle%255D%3DUpload
>
>
> Is that the right content for the signature base string? Is the file name
> or file content supposed to be accounted for in the signature base string at
> all?
I assume that track[title]=Upload is not a part of the query string so
my answer is: no.
The request body should only be included when you do a POST with
content-type application/x-www-form-urlencoded (see
http://oauth.net/core/1.0/#anchor14 9.1.1. Normalize Request
Parameters). So you should leave those parameters out of the signature
base string.
http://gist.github.com/146876 is small ruby script I wrote to verify
signing of requests and also making the process understandable.
I hope this helps.
>I assume that track[title]=Upload is not a part of the query string so
> Signature Base String:
>
> POST&http%3A%2F%2Fapi.soundcloud.com%2Ftracks&oauth_consumer_key%3DTU7rx9XbIK0bAoB1Bgqw%26oauth_nonce%3Di4ug2df2b1b307e11943%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1255535658%26oauth_token%3Dv4kJxpkzlmrlKjfY6NJjkA%26oauth_version%3D1.0%26track%255Btitle%255D%3DUpload
>
>
> Is that the right content for the signature base string? Is the file name
> or file content supposed to be accounted for in the signature base string at
> all?
my answer is: no.
The request body should only be included when you do a POST with
content-type application/x-www-form-urlencoded (see
http://oauth.net/core/1.0/#anchor14 9.1.1. Normalize Request
Parameters). So you should leave those parameters out of the signature
base string.
http://gist.github.com/146876 is small ruby script I wrote to verify
signing of requests and also making the process understandable.
I hope this helps.
--
OAuth Protocol Parameters are sent from the Consumer to the Service Provider in one of three methods, in order of decreasing preference:
Internal Server Error is of course something we want to avoid.
>
> I tried passing the request parameters (oauth_*) under the Authorization
> header (method 1), but that didn't work at all (for file upload or for
> /me/). Does SoundCould support this method of providing the request
> parameters?
>
> I also realized that based on 2., placing the request parameters (oauth_*)
> into the body of the request doesn't help (since the content-type is
> multipart/form-data). Is that correct?
>
> In any case, I was left with the 3rd method so I stuck the oauth_*
> parameters into the query. This is what consistently gives me an Internal
> Server Error for the file upload case.
We support all three methods of passing the oauth parameters and, as
the spec says, we prefer the first method.
I've successfully uploaded files and below are some data from the request:
********************************************************************************
Signature Base String
********************************************************************************
POST&http%3A%2F%2Fapi.soundcloud.com%2Ftracks&oauth_consumer_key%3DgLnhFeUBnBCZF8a6Ngqq7w%26oauth_nonce%3DyvyM7hwT2zi1qrnddZZzcFlY1YQ02VO3UPofeguuGA%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1255939172%26oauth_token%3DgScOQnEj6UjXqpmR6YqE4A%26oauth_version%3D1.0
********************************************************************************
Authorization Header
********************************************************************************
OAuth oauth_nonce="yvyM7hwT2zi1qrnddZZzcFlY1YQ02VO3UPofeguuGA",
oauth_signature_method="HMAC-SHA1", oauth_timestamp="1255939172",
oauth_consumer_key="gLnhFeUBnBCZF8a6Ngqq7w",
oauth_token="gScOQnEj6UjXqpmR6YqE4A",
oauth_signature="YL2oB1nDNe3q2oTRFJsPePJ9ozM%3D", oauth_version="1.0"
********************************************************************************
Request Body
********************************************************************************
--boundary-one-742652124
content-disposition: form-data; name="track[title]"
This is uploaded from plain.rb
--boundary-one-742652124
content-disposition: form-data; name="track[sharing]"
private
--boundary-one-742652124
content-disposition: form-data; name="track[asset_data]"; filename="knaster.mp3"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
ID3CTT2Vinyl Scratch 07COMengiTunPGAP0TENiTunes v7.4.2COMhengiTunNORM
000000A7 000000A5 00000BD1 00000BA8 00000605 00000605 00007E66
00007EBD 00000068 00000068COM?engiTunSMPB 00000000 00000210 0000089C
00000000000227D4 00000000 00011E88 00000000 00000000 00000000 00000000
00000000 00000000 *** The rest of the file contents are omitted. ***
--boundary-one-436885369--
********************************************************************************
Internal Server Error is of course something we want to avoid.
...
We support all three methods of passing the oauth parameters and, as
the spec says, we prefer the first method.
I've successfully uploaded files and below are some data from the request:
Thank you for finding this, it seems like a "low level" error and I'll
need to assess what is expected of clients and servers when doing
multipart uploads.
Good look with the project!
- Hannes
I'v removed the ; and changed the order to the same as the above
sample by Hannes, and now I get Internal Server Error instead.
Here is a TCP-dump of it: http://josefsson.playven.com/soundcloud.dump
It includes all the data that is being sent and recived.