Add tracks to "Unable to parse request body"

Hi,

I sometime got this error message when trying to add tracks to a playlist with the Apple Music API without specific reason (as my code is always the same):

"{"errors":[{"id":"BBHVSNE2ESJ2SB24UDX7RAUJLE","title":"Invalid Request Body","detail":"Unable to parse request body","status":"400","code":"40007"}]}"


Seems to be an error with some track IDs sent, but can't reproduce as the same request will sometime work/sometime no.

The error message is not specific, must be improved and having more details.


Here's the associate "data" field with IDs:


[{"id":"1443234959","type":"songs"},{"id":"260758659","type":"songs"},{"id":"1440822258","type":"songs"},{"id":"1440822404","type":"songs"},{"id":"201274644","type":"songs"},{"id":"295784137","type":"songs"},{"id":"1443299896","type":"songs"},{"id":"1281713004","type":"songs"},{"id":"606057317","type":"songs"},{"id":"606057325","type":"songs"},{"id":"663114226","type":"songs"},{"id":"606057321","type":"songs"},{"id":"676287692","type":"songs"},{"id":"251948354","type":"songs"},{"id":"576655099","type":"songs"},{"id":"573962555","type":"songs"},{"id":"465744628","type":"songs"},{"id":"510168339","type":"songs"},{"id":"1440902768","type":"songs"},{"id":"1443455810","type":"songs"},{"id":"1443455804","type":"songs"},{"id":"924035389","type":"songs"},{"id":"1440859596","type":"songs"},{"id":"434815633","type":"songs"},{"id":"858517165","type":"songs"},{"id":"1440863108","type":"songs"},{"id":"1440812204","type":"songs"},{"id":"470758198","type":"songs"},{"id":"1377826892","type":"songs"},{"id":"630283721","type":"songs"},{"id":"1263704271","type":"songs"},{"id":"821681054","type":"songs"},{"id":"158614534","type":"songs"},{"id":"510225627","type":"songs"},{"id":"50235014","type":"songs"},{"id":"50235016","type":"songs"},{"id":"400946435","type":"songs"},{"id":"715891658","type":"songs"},{"id":"1440819062","type":"songs"},{"id":"1440818897","type":"songs"},{"id":"716192621","type":"songs"},{"id":"487245253","type":"songs"},{"id":"572884947","type":"songs"},{"id":"1090088442","type":"songs"},{"id":"464532969","type":"songs"},{"id":"807600196","type":"songs"},{"id":"1440814009","type":"songs"},{"id":"1440858896","type":"songs"},{"id":"721253705","type":"songs"},{"id":"1440858175","type":"songs"},{"id":"893013350","type":"songs"},{"id":"1383521769","type":"songs"},{"id":"1270065322","type":"songs"},{"id":"721216982","type":"songs"},{"id":"1440873977","type":"songs"},{"id":"1440862244","type":"songs"},{"id":"1440874203","type":"songs"},{"id":"721210538","type":"songs"},{"id":"721210544","type":"songs"},{"id":"929825615","type":"songs"},{"id":"1440827392","type":"songs"},{"id":"1444073621","type":"songs"},{"id":"943946671","type":"songs"},{"id":"1440829431","type":"songs"},{"id":"580695853","type":"songs"},{"id":"929825619","type":"songs"},{"id":"929825624","type":"songs"},{"id":"383458589","type":"songs"},{"id":"466581404","type":"songs"},{"id":"849069529","type":"songs"},{"id":"1440813456","type":"songs"},{"id":"1440854619","type":"songs"},{"id":"545398147","type":"songs"},{"id":"545398139","type":"songs"},{"id":"258642190","type":"songs"},{"id":"593148438","type":"songs"},{"id":"295224410","type":"songs"},{"id":"616276070","type":"songs"},{"id":"721686248","type":"songs"},{"id":"1443148562","type":"songs"},{"id":"1454638588","type":"songs"},{"id":"1432060582","type":"songs"},{"id":"947701032","type":"songs"},{"id":"514504434","type":"songs"},{"id":"1443223753","type":"songs"},{"id":"302989197","type":"songs"},{"id":"683639109","type":"songs"},{"id":"1440491261","type":"songs"},{"id":"255289443","type":"songs"},{"id":"1440934590","type":"songs"},{"id":"1440935894","type":"songs"},{"id":"1440935899","type":"songs"},{"id":"1440935902","type":"songs"},{"id":"1440935908","type":"songs"},{"id":"1440935913","type":"songs"},{"id":"1440936162","type":"songs"},{"id":"1440936171","type":"songs"},{"id":"1440936181","type":"songs"},{"id":"1440936283","type":"songs"},{"id":"1440936426","type":"songs"},{"id":"1440936463","type":"songs"},{"id":"1440936162","type":"songs"},{"id":"1440936474","type":"songs"},{"id":"1440936482","type":"songs"},{"id":"1443799539","type":"songs"},{"id":"1443920265","type":"songs"},{"id":"1440783474","type":"songs"},{"id":"260042093","type":"songs"},{"id":"1434740155","type":"songs"},{"id":"714587248","type":"songs"},{"id":"486040195","type":"songs"},{"id":"1443999002","type":"songs"},{"id":"258633458","type":"songs"},{"id":"1442258767","type":"songs"},{"id":"1440857725","type":"songs"},{"id":"1440857729","type":"songs"},{"id":"1440857730","type":"songs"},{"id":"400135918","type":"songs"},{"id":"724223119","type":"songs"},{"id":"1300702242","type":"songs"},{"id":"1452792498","type":"songs"},{"id":"207316133","type":"songs"},{"id":"251081851","type":"songs"},{"id":"1440824580","type":"songs"},{"id":"281752590","type":"songs"},{"id":"167651542","type":"songs"},{"id":"545398137","type":"songs"},{"id":"545398138","type":"songs"},{"id":"1440754487","type":"songs"},{"id":"1440867183","type":"songs"},{"id":"1440885797","type":"songs"},{"id":"929825616","type":"songs"},{"id":"1083641053","type":"songs"},{"id":"303682919","type":"songs"},{"id":"1440858336","type":"songs"},{"id":"941366737","type":"songs"},{"id":"929825619","type":"songs"},{"id":"1031416183","type":"songs"},{"id":"1440815622","type":"songs"},{"id":"1110121977","type":"songs"},{"id":"821681054","type":"songs"},{"id":"1440846373","type":"songs"},{"id":"1370924883","type":"songs"},{"id":"1444896450","type":"songs"},{"id":"1251713725","type":"songs"},{"id":"1342658106","type":"songs"},{"id":"714287575","type":"songs"},{"id":"1440853242","type":"songs"},{"id":"1351991983","type":"songs"},{"id":"323489062","type":"songs"},{"id":"298396531","type":"songs"},{"id":"1440858901","type":"songs"},{"id":"283567164","type":"songs"},{"id":"721215888","type":"songs"},{"id":"217503142","type":"songs"},{"id":"1440661140","type":"songs"},{"id":"1445039161","type":"songs"},{"id":"1440889001","type":"songs"},{"id":"308522273","type":"songs"},{"id":"1440925452","type":"songs"},{"id":"1444876145","type":"songs"},{"id":"1277187683","type":"songs"},{"id":"1452802030","type":"songs"},{"id":"724349113","type":"songs"},{"id":"1440771048","type":"songs"},{"id":"692225584","type":"songs"},{"id":"255277764","type":"songs"},{"id":"580695853","type":"songs"},{"id":"1081573445","type":"songs"},{"id":"260041613","type":"songs"},{"id":"1031416183","type":"songs"},{"id":"943946671","type":"songs"},{"id":"1440817504","type":"songs"}]


Thank you for your help.

Are you sure the data sent in your request is actually a LibraryPlaylistTracksRequest, as shown in the example here:


https://developer.apple.com/documentation/applemusicapi/add_tracks_to_a_library_playlist


In particular, do you have a top level dictionary with a single entry with the "data" key and the track list array as its value? Did you make a POST request?

Yes, as I said, we are doing thousands of "add tracks to a library" playlists requests per day, so the code is good and as you can see in the example, IDs seems to be good too.

If this is at least intermittently reproducible for a specific list of tracks, I think the Apple Music team would appreciate a bug report so they can investigate. Actually, a bug report showing the request body and the response error body text for a failing case would be useful even if reproducibility is difficult.


Have you tried established a threshold number of tracks below which there are no failures? In particular, if you always add tracks to the playlist one at a time, does that ever fail? If you can find a regularity here, that would be a big help.

The issue is that => "If this is at least intermittently reproducible for a specific list of tracks".

Because we got the error (with a unique ID at least), but retrying to do the request a couple of seconds later could make it works this time (even if it's exactly the same request). So no, it's could not be "reproductible".


And unfortunately no regularity here. Could happen for a body of 1 track same as request body of 100 tracks for example. I have open a ticket in the Apple Dev Feedback with the error ID and the associate body, wait and see.


But this is happening more and more often and finally succeed at third time only sometimes.

Strange thing I'm the only one to got this error here (you don't have logs from other users with this 40007 error" ?).

Was a solution for this ever found? I am having the exact same issue recently with no changes to my code.

A ticket has been opened, but they are still not able to reproduce the issue on their side...

For now, I have changed my code and doing insert one by one... very slow but a sure method 😉

Could you post the bug report number here, please?

Sure, here you go => FB7358221

We identified an issue affecting some requests for adding tracks that has been resolved. Thank you for the report.

Hi !

I'm now instead of the previous message error getting:

=> "Unable to update tracks" from the API when trying to add tracks to a playlist.


Here is an example of a list of songs sent to have this error message :


[{"id":"1045191907","type":"songs"},{"id":"1444873737","type":"songs"},{"id":"1081697965","type":"songs"},{"id":"1442277862","type":"songs"},{"id":"1064798417","type":"songs"},{"id":"1073169694","type":"songs"},{"id":"1445174755","type":"songs"},{"id":"1253076931","type":"songs"},{"id":"1098730576","type":"songs"},{"id":"1364129786","type":"songs"},{"id":"1445019394","type":"songs"},{"id":"1001771055","type":"songs"},{"id":"1440856655","type":"songs"},{"id":"1440834968","type":"songs"},{"id":"1319606196","type":"songs"},{"id":"1108737327","type":"songs"},{"id":"1496802229","type":"songs"},{"id":"726373148","type":"songs"},{"id":"1108987771","type":"songs"},{"id":"1170699703","type":"songs"},{"id":"1182107728","type":"songs"},{"id":"1254533944","type":"songs"},{"id":"1118431592","type":"songs"},{"id":"1050112236","type":"songs"},{"id":"1442215697","type":"songs"},{"id":"1398208561","type":"songs"},{"id":"1000069678","type":"songs"},{"id":"1444869589","type":"songs"},{"id":"1164239241","type":"songs"},{"id":"1120405215","type":"songs"},{"id":"1498632796","type":"songs"},{"id":"1374863253","type":"songs"},{"id":"1183998298","type":"songs"},{"id":"1452669850","type":"songs"},{"id":"1452670649","type":"songs"},{"id":"4332986","type":"songs"},{"id":"1116682200","type":"songs"},{"id":"1452623382","type":"songs"},{"id":"1129764619","type":"songs"},{"id":"1440620924","type":"songs"},{"id":"849428987","type":"songs"}]


Any idea ? I can provide you more examples of lists like this which are generating the error.


Thank you for your help.

Hi, I came here to report that I'm also having this issue.

Here's an example of a request payload that fails with "Unable to update tracks" and a response code of 500:

{"data":[{"id":"1231174877","type":"songs"},{"id":"1643544720","type":"songs"}]}

An inconvenient side effect from this is that when you include a song ID that usually goes through, you get no errors or messages back indicating that other songs didn't make it. This makes it difficult to handle errors and take the appropriate actions.

Years later and still got the exact same issue from time to time "Unable to update tracks". And as @zrod mentionned; having only one track that is generating the error is failing the whole batch addition. The result is probably having to do addition one by one wich is time and request consumming for us and YOUR servers too.

Any fixes soon? Or at least ideas to what is going on?

Add tracks to "Unable to parse request body"
 
 
Q