Search code examples
apigoogle-chromejsonpgoogle-chrome-devtoolssoundcloud

Invalid javascript/JSONP response from Soundcloud API


When I include this url as a <script> in my HTML document, Chrome does not call my callback function, whereas it works perfectly for other urls returned by soundcloud's resolve api.

After a long investigation using Chrome Dev Tools, I finally found out that the javascript returned by that call fires a SyntaxError (cf the screenshot below).

enter image description here

How can I get my callback function to be called as usual for that file?


Solution

  • DevTools actually pinpoint the issue:

    \u2029 character in JSON

    There is an unallowed character (\u2028) in the response. SoundCloud messed up sanitizing that. This JSONP response is invalid in all browsers.

    To work around it, you can simply fetch the JSON file directly. SoundCloud CORS setup seems to allow that.