Hi - the music service Tidal has an undocumented API, and I am trying to use Fiddler to turn an API call into something I could code with javascript. I tried taking the raw request and the relevant headers (including the auth token), and making a fetch request, but I'm getting a `400 bad request` error. How do I make a successful request based off the data I'm getting from tidal?
For more details:
A raw request originating from using their desktop app looks like this:
GET https://api.tidal.com/v2/my-collection/playlists/folders?folderId=root&includeOnly=&offset=0&limit=50&order=DATE&orderDirection=DESC&countryCode=US&locale=en_US&deviceType=DESKTOP HTTP/1.1 Host: api.tidal.com Connection: keep-alive Cache-Control: max-age=0 sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="102" authorization: Bearer [MY_TOKEN] if-none-match: "09e94392f43a10130f3782b0bd97b5c86" sec-ch-ua-mobile: ?0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) TIDAL/2.33.2 Chrome/102.0.5005.167 Electron/19.0.14 Safari/537.36 sec-ch-ua-platform: "macOS" Accept: */* Origin: https://desktop.tidal.com Sec-Fetch-Site: same-site Sec-Fetch-Mode: cors Sec-Fetch-Dest: empty Referer: https://desktop.tidal.com/ Accept-Encoding: gzip, deflate, br Accept-Language: en-US
I am trying to make that same call using javascript / node (I could potentially use another language, but this is what I'm most familiar with).
const fetch = require("node-fetch");
const API_ADDRESS = "https://api.tidal.com/v2";
const TEMP_REQUEST = "folderId=root&includeOnly=&offset=0&limit=50&order=DATE&orderDirection=DESC&countryCode=US&locale=en_US&deviceType=DESKTOP HTTP/1.1";
const fetchMusic = async () => {
const response = await fetch(`${API_ADDRESS}${TEMP_REQUEST}}`, {
method: "POST",
headers: {
Host: "api.tidal.com",
Authorization: `${MY_TOKEN}`,
},
});
const data = await response.json();
console.log(data);
};
fetchMusic();
when I do this, I get an error like:
{
timestamp: '2022-11-08T16:08:34.517+0000',
path: '/v2/my-collection/playlists/folders',
status: 500,
error: 'Internal Server Error',
message: '400 Bad Request from POST http://10.10.128.76:8080/v1/oauth2/internal/token/validate',
requestId: 'eb83f8d5-486790'
}