Search code examples
vimeovimeo-api

upload.approach "pull" request returns success message, but the content isn't valid


There does not exist an official Vimeo API SDK for Coldfusion, so I wrote one based on the official PHP code. In the end, we're only interested in what JSON string Vimeo sees when it receives a request anyway, right? I'm attempting to do a PULL approach, and I receive a video ID, link, status of "processing" etc when I run the script. The video appears in my account online as "Pending". This is the JSON content of my request: Headers:

POST https://api.vimeo.com/me/videos
{ 
  "Content_Type": "application/json",
  "Authorization": "Bearer 7b8686f6d7cb....65990",
  "Accept": "application/vnd.vimeo.*+json; version=3.4"
}

body:

{
  "upload": {
    "approach":"pull",
    "size":30003213,
    "link":"https://mysite.me/api/index.cfm/video?PK=Na6z6ZZMQ&SI=45rtt4423"},
    "name":"Employee1.mp4"
  }
}

The response I receive back from Vimeo includes the following data (obviously this is not the entire response):

{
  "Statuscode": "201 Created",
  "Filecontent": {
    "uri":"/videos/3...393",
    "name":"Untitled",
    "description":null,
    "link":"https://vimeo.com/3...393"
  },
  "app":{
    "name":"My Vimeo App Name",
    "uri":"/apps/14...6"
  },
  "status":"uploading",
  "resource_key":"0b83....d49dc",
  "upload":{
    "status":"in_progress",
    "complete_uri":null,
    "approach":"post",
    "size":null, 
    "redirect_url":null,
    "link":null
  },
  "transcode":{"status":"in_progress"}
}

I can't seem to get Vimeo to recognize this as a "pull" approach, nor recognize the file name, size, etc. It appears that the request is successful, but the video in "My Videos" on Vimeo never completes uploading or transcoding, has no name, doesn't honor my settings for privacy or other options, and seems to be some sort of processing error.

I'll be glad to share some ColdFusion code with any experienced with it, but I feel like the issue probably lay with the compiled JSON rather than ColdFusion.


Solution

  • Solution: when sending the requestes via ColdFusion, instead of sending the JSON content like this:

    <cfhttpparam type="body" value="{"upload":{"approach":"pull","size":30003213,"link":"https://example.com/api/index.cfm/video?PK=Na6z6Zp4ca&CK=4EP56DM566&SI=6868"},"name":"EmployeeProfile.mp4"}" />
    

    the parameters should be sent like this:

    <cfhttpparam type="formField" encoded="false" name="upload.approach" value="pull" />
    <cfhttpparam type="formField" encoded="false" name="upload.size" value="30003213" />
    <cfhttpparam type="formField" encoded="false" name="upload.link" value="https://example.com/api/index.cfm/video?PK=Na6z6Zp4ca&CK=4EP56DM566&SI=6868" />
    

    Not sure why, but when you send a POST request to Vimeo from ColdFusion, Vimeo does not recognize any of the JSON body of the cfhttpparam. You must use type="formField".