'Why am I getting an Error Parsing JSON Response with this JSON?
When making a POST request to the Spotify API using https://github.com/JMPerez/spotify-web-api-js I keep getting back a 400 bad request with the response "Error Parsing JSON'
The JSON from the request headers looks valid to me.
{"uris":"spotify:track:5qmq61DAAOUaW8AUo8xKhh"}
const addTrackToPlaylist = (track) => {
spotifyApi.addTracksToPlaylist('4EiIrcKLn4P7xdHOj6tZ9Y', `spotify:track:${track}`)
.then( (data) => {
console.log(data);
});
}
I should get back a 201 and not the 400.
Solution 1:[1]
The addTracksToPlaylist from spotify-web-api-js takes in an array of spotify uri's even if it is only 1 track.
You would need to update your request to include the track in an array:
spotifyApi.addTracksToPlaylist('4EiIrcKLn4P7xdHOj6tZ9Y', [`spotify:track:${track}`])
See https://github.com/JMPerez/spotify-web-api-js/blob/master/src/spotify-web-api.js#L779
Solution 2:[2]
We are sorry that you could not complete the SEO data optimization. Can you please try resetting our indexables in the database tables by following the steps below?
- Install & activate the Yoast Test Helper plugin
- Go to Tools > Yoast Test
- Locate the Yoast SEO section and click on the ‘Reset indexables tables & migrations’, ‘Reset Prominent words calculation’, and ‘Reset Internal link counter’ buttons. After each click, the page will reload to confirm that each reset was successful. Note: Resetting the optimization doesn’t undo any of the hard work you’ve put into the plugin as the SEO data is also stored in WordPress’ default tables. It’ll just reset the custom Yoast tables that contain the combined data pulled from those default tables.
- Go to SEO > Tools, and under SEO data, click the “Start SEO data optimization” button to allow Yoast to rescan your content.
For your site’s health and safety, we recommend creating regular backups of your site and database. This is especially important before making important changes on your website.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kevin Guebert |
| Solution 2 | Phpcable Web Developers |
