2015-08-16 76 views
0

我懷疑Soundcloud的某些東西已經改變,因爲我的代碼並沒有改變,去年效果不錯。Soundcloud - 創建播放列表的紅寶石得到422(#soundcloud-ruby)

我看到:

Error: HTTP status: 422 Unprocessable Entity, Status Code: 422, playlist_struct:{:title=>"Y11 - REVO - Sop", :description=>"Y11 - REVO - Sop newchoir", :tag_list=>"Sop", :tracks=>"219269586", :format=>"json", :oauth_token=>"..."} 

我的oauth_token工作正常。

我打電話:

new_playlist = @client.post('/playlists', playlist_struct) 

凡@client定義使用https://github.com/soundcloud/soundcloud-ruby爲:

@client = SoundCloud.new({ 
          :client_id  => clientId, 
          :client_secret => clientSecret, 
          :username  => email, 
          :password  => password 
         }) 

而且playlist_struct是每個錯誤消息。

想法感激!

問候,M.

全碼:

require 'rubygems' 
require 'soundcloud' 
require 'pp' 
require 'logger' 

def login 
    # http://soundcloud.com/you/apps 
    clientId = '...' 
    clientSecret = '...' 
    email = '...' 
    password = '...' 


    # register a new client, which will exchange the username, password for an access_token 
    # NOTE: the SoundCloud API Docs advise not to use the user credentials flow in a web app. 
    # In any case, never store the password of a user. 
    @client = SoundCloud.new({ 
          :client_id  => clientId, 
          :client_secret => clientSecret, 
          :username  => email, 
          :password  => password 
          }) 

    # print logged in username 
    puts"h1. Logged in as " + @client.get('/me').username 

    # updating the users profile description 
end 

login() 


playlist_struct = { 
    :title => "Hello" 
} 


    new_playlist = @client.post('/playlists', playlist_struct) 
    @log.info ' OK: '+new_playlist.permalink_url 
+0

您是否嘗試更新您的紅寶石? –

+0

嗯,好點,我沒有。我剛剛更新爲soundcloud-0.3.2.gem(100%) 成功安裝了soundcloud-0.3.2。仍然失敗。 :( –

+0

只需更新gem並不會改變應用程序所使用的版本,您應該'捆綁更新'以使這些更改在'Gemfile.lock'中生效。另外,請確保您沒有執行任何版本的'Gemfile'中的soundcloud gem。 –

回答

0

貌似playlist_struct現在需要包括

播放列表:{ ... }

圍繞內容。

由於代碼在手之前工作了幾年,我敢打賭,這是對API的無聲更改。