Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Queue function returning 503 error

Solved!

Queue function returning 503 error

None of the below information is required. However, the more you provide the easier it will be for us to try and help.

Plan

Premium

Country

France

Device

(Raspberry Pi)

os

debian

 

My Question or Issue

I’m trying to use the API in order to call Spotify from a Ruby on Rails application. 
For that I’m using the gem rspotify. 

Everything works fine except one function was not implemented : queue function. 
So I developped it myself. 
here is the piece of code I added : 

def queue(device_id = nil, uri)  url = "me/player/queue?uri=#{uri}"  url = device_id.nil? ? url : "#{url}?device_id=#{device_id}"

  User.oauth_put(@user.id, url, {})
end

 

Note that this is exactly similar to the play function of rspotify which allows to directly play a song and which works.

here is the full code with other working functions : 

https://github.com/guilhermesad/rspotify/blob/master/lib/rspotify/player.rb

When trying to call that, I get the following error: 

503 Service Unavailable

 

here is an example showing the play function working and this one returning the error. 

> me = RSpotify::User.new(hash)
> player = RSpotify::Player.new(me)
> track = RSpotify::Track.search('Know')[0]
>
> player.play_track(track.uri)
 => nil
> player.queue(track.uri)warning: Overriding "Content-Type" header "application/json" with "application/x-www-form-urlencoded" due to payloadTraceback (most recent call last):
        1: from (irb):82
RestClient::ServiceUnavailable (503 Service Unavailable)

 

Could anyone help me on this?

 

 

 

 

Reply

Accepted Solutions
Marked as solution

Problem is solved.

The issue was coming from the fact that a PUT method was used instead of a POST.
Here is the fixed code:

def queue(device_id = nil, uri)
  url = "me/player/queue?uri=#{uri}"
  url = device_id.nil? ? url : "#{url}&device_id=#{device_id}"
  User.oauth_post(@user.id, url, {})
end

 

Hope it will save some time to others

 

 

View solution in original post

2 Replies
Marked as solution

Problem is solved.

The issue was coming from the fact that a PUT method was used instead of a POST.
Here is the fixed code:

def queue(device_id = nil, uri)
  url = "me/player/queue?uri=#{uri}"
  url = device_id.nil? ? url : "#{url}&device_id=#{device_id}"
  User.oauth_post(@user.id, url, {})
end

 

Hope it will save some time to others

 

 

Glad you were able to resolve this, @Eagleone!

Suggested posts