Quick example of posting videos to Brightcove

A reader asked for help using Brightcove’s API to upload a video using ColdFusion. While I do not plan on writing a full wrapper, or going into great detail, I thought a quick blog post on what he tried, and why it failed, could help others who plan on using the service.
Let’s first look at his original code and a description of the problem he had.

Even without knowing the API, you can see that it makes use of JSON to pass parameters about the upload. This code won’t work at all because you can’t mix a httpparam of type body with type file. The API docs though seemed to imply you needed to send the JSON values as the body. I first attempted to simply save the JSON to the file system and send it as a second file. This didn’t work. I then dig a bit of digging and discovered this forum post by the Brightcove team: http://forum.brightcove.com/brgh/board/message?board.id=Developer_2&message.id=85

It pointed out that the JSON data could be sent as a form field, and it showed that my reader was missing a bit of data as well. Oddly - another issue was the order of the HTTP params. I can’t image why this makes a difference, but if the JSON data isn’t the first httpparam, then nothing else works. The final, working code, is below. Note - I removed his API key so you can’t run this as is.

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos.
If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.