Search code examples
vimeovimeo-api

redirect_url not being respected in a Vimeo form-based upload


Using the docs from here: https://developer.vimeo.com/api/upload/videos This is my request body, POSTed to api.vimeo.com/me/videos:

upload: { approach: "post", redirect_url: "https://www.example.com/app/video", size: 5253880 }

I am getting back a valid upload response, and able to submit the upload.form just fine to upload my video, however am redirected to the default Vimeo success screen instead of my own /app/video screen as desired. There's a redirect_uri property on the response which is null, so for some reason they seem to be ignoring my redirect_url. What am I missing here?

Here is the complete code being used to create the request:

    const size = e.target.files[0].size;
    const XHR = new XMLHttpRequest();
    const uploadParams = {
        upload: {
            approach: 'post',
            redirect_url: 'https://www.example.com/app/video',
            size,
        },
    };

    XHR.addEventListener('load', $scope.upload, false);
    XHR.addEventListener('error', $scope.uploadError, false);
    XHR.open('POST', 'https://api.vimeo.com/me/videos');
    XHR.setRequestHeader('Authorization', `Bearer ${vimeoToken}`);
    XHR.send(JSON.stringify(uploadParams));

Solution

  • Just figured it out, leaving this up for anyone else who misses this part of the docs: you need to set the Accept header to "application/vnd.vimeo.*+json;version=3.4" which I wasn't doing, and it was still letting me upload, but just not processing my request params.