1

I'm trying to watch spotify packages on the emulator, but the data sent and received are corrupted. How can I solve this problem?

İmages:

enter image description here enter image description here enter image description here

I tried reading the data many times but it always looks like this. I want to see the data properly in JSON form.

seadhy
  • 11
  • 3

2 Answers2

1

This data is not corrupted, it's just not in the format you want.

You can see the format by looking at the content-type header, which says application/protobuf.

This is not JSON data. Instead it's Protobuf, which is a general-purpose serialization format, similar to JSON or XML, but designed to be faster to process and smaller to transfer, in part by being sent as raw binary data, instead of readable strings.

To deserialize this 100% correctly, you will need the Protobuf schema for the API you're talking to (a .proto file). In many cases, unless this is your own or a publicly documented API, that's not going to be available.

You can still try to decode the data into raw data types though, although that might not allow you to decode all information immediately. There's more info on that here: raw decoder for protobufs format. Decoding data like this works best using the protoc command-line tool, but you may also be able to decode this data using https://protobuf-decoder.netlify.app/. Note that that takes hex data, not a raw string like you have here, so you'll have to pick the 'Hex' option for the body in HTTP Toolkit to copy the hex codes over instead.

Tim Perry
  • 11,766
  • 1
  • 57
  • 85
0

I can only extract data from here, how can I use them with python requests? I want to convert them to dictionary data type. Or can we solve this using https://github.com/spotify/proto-requests? I'm trying to write a program on Spotify.

seadhy
  • 11
  • 3