Code Monkey home page Code Monkey logo

Comments (5)

sputnick1124 avatar sputnick1124 commented on August 11, 2024

For reference, this is what I see when interacting with the endpoint through the (API

{
  "error": {
    "status": 404,
    "message": "Player command failed: No active device found",
    "reason": "NO_ACTIVE_DEVICE"
  }
}

The Response object from reqwest, however, does not seem to provide any access to that json object. It would seem I am potentially missing something obvious, but I don't know what.

Response { 
    url: "https://api.spotify.com/v1/me/player/play?device_id=4a205e1455078ac27724255dd891265738f17dfe", 
    status: 404, 
    headers: {
        "content-type": "application/json; charset=utf-8",
        "cache-control": "private, max-age=0",
        "access-control-allow-origin": "*",
        "access-control-allow-headers":"Accept, App-Platform, Authorization, Content-Type, Origin, Retry-After, Spotify-App-Version",
        "access-control-allow-methods": "GET, POST, OPTIONS, PUT, DELETE, PATCH",
        "access-control-allow-credentials": "true",
        "access-control-max-age": "604800",
        "transfer-encoding": "chunked",
        "date": "Sat, 09 Nov 2019 13:41:32 GMT",
        "via": "1.1 google",
        "alt-svc": "clear"
    }
}

from rspotify.

ramsayleung avatar ramsayleung commented on August 11, 2024

Do you mean that the reqwest will hide the error message from the response, could you help me reproduce this case by doing it step by step?

from rspotify.

TimotheeGerber avatar TimotheeGerber commented on August 11, 2024

I am only guessing here, but I think that @sputnick1124 tried to print the reqwest's Response with something like:

println!("{:#?}", response);

Unfortunately, the implementation of the Debug trait for Response does not show the body of the response, only the URL, status and headers (see the implementation here). It leads @sputnick1124 to believe that the JSON returned by Spotify is not in the Response. But it is. You can get the body with the .text(), .bytes() or even .json() methods.

from rspotify.

sputnick1124 avatar sputnick1124 commented on August 11, 2024

@TimotheeGerber is correct. I was naively just printing out the Response object and neglected to go look at it's implementation. I have a clear idea now of what I am trying to do. I'll work on a PR and get that up sometime this week.

Thanks, @TimotheeGerber!

from rspotify.

sputnick1124 avatar sputnick1124 commented on August 11, 2024

PR is open. Please provide any comments/suggestions for improvement.

from rspotify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.