Vimeo uploading. Cannot get complete_uri field in

2019-06-26 04:44发布

问题:

I've been fiddling quite a bit with my uploading to vimeo.

  1. I've made a ticket request.
  2. I've uploaded the file.
  3. I've checked the file if its uploaded.
  4. I need to run the method DELETE with the complete_uri response i should get from my ticket. However, im not receiving any complete_URI from the ticket response.

Here is my code:

public static dynamic GenerateTicket()
        {
            const string apiUrl = "https://api.vimeo.com/me/videos?type=streaming";
            var req = (HttpWebRequest)WebRequest.Create(apiUrl);
            req.Accept = "application/vnd.vimeo.*+json;version=3.0";
            req.Headers.Add(HttpRequestHeader.Authorization, "bearer " + AccessToken);
            req.Method = "POST";
            var res = (HttpWebResponse)req.GetResponse();
            var dataStream = res.GetResponseStream();
            var reader = new StreamReader(dataStream);
            var result = Json.Decode(reader.ReadToEnd());

            return result;
        }

This response gives me:

  • form
  • ticket_id
  • upload_link
  • upload_link_secure
  • uri
  • user

In order to finish my upload i need to run step 4 in this guide: https://developer.vimeo.com/api/upload

Sending parameter type=streaming as body:

ASCIIEncoding encoding = new ASCIIEncoding();
            string stringData = "type=streaming"; //place body here
            byte[] data = encoding.GetBytes(stringData);

            req.Method = "PUT";
            req.ContentLength = data.Length;

            Stream newStream = req.GetRequestStream();
            newStream.Write(data, 0, data.Length);
            newStream.Close();

回答1:

At the moment, type=streaming must be sent in the body of the request, not as a url parameter.

This will probably change to allow either option.



回答2:

the important point is :

"The first thing you need to do is request upload access for your application. You can do so from your My Apps page."

If you get all values without complete_uri, it means: you dont have an upload access token. So go to your apps and make an upload request