Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid response format when using sendRequest on android #113

Open
idanlo opened this issue Mar 28, 2019 · 1 comment
Open

Invalid response format when using sendRequest on android #113

idanlo opened this issue Mar 28, 2019 · 1 comment

Comments

@idanlo
Copy link

idanlo commented Mar 28, 2019

i'm trying to reach this endpoint https://developer.spotify.com/documentation/web-api/reference/follow/check-user-following-playlist/, my code looks like this:

Spotify.getMe().then(res => {
    Spotify.sendRequest(`v1/playlists/${playlistId}/followers/contains`, "GET", { ids: res.id }, false)
        .then(isFollowing => {
            console.log(isFollowing)
    })
})

but I get the following error:

Possible Unhandled Promise Rejection:
Error: Invalid response format

i tried to do this request with the same data on their web console and it worked.

I only have an android device so I don't know what happens on IOS.

@kevinguebert
Copy link

kevinguebert commented Apr 16, 2019

@idanlo I think I've run into a similar issue but I would need to validate before really diving into it. If you through a catch after you then, do you mind outputting what it shows?
So it would look like this:

Spotify.getMe().then(res => {
    Spotify.sendRequest(`v1/playlists/${playlistId}/followers/contains`, "GET", { ids: res.id }, false)
        .then(isFollowing => {
            console.log(isFollowing)
         }).catch(err => {
            console.log(err)
         })
})

What I'm seeing in my console for both playlists/${playlistID}/followers/contains GET request and the playlists/${playlistID}/followers DELETE request is the error message of Error: Service not found

I'm on iOS but I would imagine the same thing...so I tried going into RNSpotify.m and debugging and I got as far as inspecting the request on line 961 of [[SPTRequest sharedHandler] performRequest:request callback:^(NSError* error, NSURLResponse* response, NSData* data)

The response from this request comes back as:
{"error": {"status": 404,"message": "Service not found"}} but again, as you say, it works in the console and postman. The SPTRequest is coming from the Spotify framework...so I wonder if it's a version problem? I don't quite know why it would fail as I would assume it is just an API request,but maybe?

If you dont mind sharing if that's the same error you are receiving I think we can debug this more. Right now it seems like there may be something up with the playlist/.../followers endpoints on the Spotify framework side.


Update - if this is still causing you problems and it is a problem with the SDK version, you can always get the access token from getSession and then use your own api request (axios, fetch, etc). to send a request to the Spotify API. I just did that and it works for me 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants