Vimeo API JsonP issue
Asked Answered
H

1

1

I am troubleshooting a jQuery ajax call to the Vimeo API that started failing in the last month or so after having worked for a while.

// Url ends up like "https://www.vimeo.com/api/v2/video/123456789.json?callback=?"
 
var url = _thumbnailUrl + vimeoId + '.json?callback=?';

$.getJSON(
    url,
    { format: "json" },
    function (data)
    {
        // Do Stuff after getting data
    }
);

The my guess is that the "?callback=?" was forcing a JSONP return but for some reason that no longer works and returns the following error. I cannot see any information on the Vimeo site about any changes to the API but perhaps they have removed the jsonp support.

text:  "parseerror"
error: "jQuery35106413737095079624_1612470990268 was not called"  

If I remove the "?callback=?", it works fine in PostMan (as you do not see CORS issues there) but in the browser it errors with:

Access to XMLHttpRequest at 'https://www.vimeo.com/api/v2/video/123456789.json' 
from origin 'https://www.myurl.com' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have tried a bunch of things, including re-formating as a straight $.ajax call and switching out various properties on the ajax call, but have not hit on a solution.

Has anyone else see this Vimeo issue? Any suggestions on how to get it to work?

Hendecagon answered 4/2, 2021 at 20:48 Comment(0)
M
2

I just encountered this issue. Got rid of the jsonp stuff and now it works fine.

Video api links are accessible directly in the browser. https://www.vimeo.com/api/v2/video/302379615.json I didn't encounter any CORS issues.

$.ajax({
    type: 'GET',
    url: '//vimeo.com/api/v2/video/' + video.id + '.json',
    dataType: 'json',
    success: function(data) {
        console.log(data);
    }
});
Mena answered 22/2, 2021 at 1:5 Comment(1)
The CORS issues that I was having got resolved when I switched to vimeo.com and ditched the www.Hendecagon

© 2022 - 2024 — McMap. All rights reserved.