Q:

Having trouble uploading WAV file to Soundcloud API

def upload_to_soundcloud
    p params
    @client = Soundcloud.new(:access_token => current_user.access_token)
    p @client
    track = @client.post('/tracks', :track => {
        :title => 'songName',
        :asset_data => params['songFile']
        })
    p track
end 

p params: 
Parameters: {"songFile"=>#<ActionDispatch::Http::UploadedFile:0x007fd4a7ba64d0 @original_filename="blob", @content_type="audio/wav", @headers="Content-Disposition: form-data; name=\"songFile\"; filename=\"blob\"\r\nContent-Type: audio/wav\r\n", @tempfile=#<Tempfile:/var/folders/fy/0hq5vn9938v5r777d_3ty0lh0000gn/T/RackMultipart20140821-83090-1c8gkb2>>}

p @client:
#<SoundCloud::Client:0x007fd4aa05bf00 @options={:site=>"soundcloud.com", :on_exchange_token=>#<Proc:0x007fd4a3e6a4b8@/Users/darrendahl/.rvm/gems/ruby-2.0.0-p481/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:11 (lambda)>, :access_token=>"--- !ruby/hash:SoundCloud::HashResponseWrapper\naccess_token:{access_token}\nscope: non-expiring\n"}>

And i get this error from the post track request:
  SoundCloud::ResponseError - HTTP status: 401 Unauthorized:
  soundcloud (0.3.2) lib/soundcloud/client.rb:152:in `handle_response'
  soundcloud (0.3.2) lib/soundcloud/client.rb:32:in `post'
  app/controllers/songs_controller.rb:22:in `upload_to_soundcloud'
  actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.13) lib/active_support/callbacks.rb:414:in `_run__629916066604458588__process_action__2865853734394445716__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__405240541142666585__call__4563851468004131522__callbacks'

This is after I have a successful login and store the soundcloud access token object in my database. The current_user.access_token part returns an access token.
Does anyone else have this problem? I am not sure if it has to do with oauth and authentication, or if the error is thrown from the type of the object that is uploaded from asset_data. The file is pretty small, so it shouldn't be because of file size. Are there only certain types of objects that can be uploaded? I tried using the tempfile in ActionDispatch object but got the same error.
I am able to log into soundcloud with the api, and my get requests to get user information works, but just not this. Thank you!

A:

As far as i read Soundcloud API Auth via Golang 401 Error right you optain an access token after succesfull login which is used on further calls, such as your post request, maybe you can try that? 

