Posted on 31st July, 2014 by Andrew Downes
In most of my blog posts I aim to reach a broad audience. I include some technical detail, but try to remain simple enough that everyone has a chance of getting something from it. In this post, I’m looking specifically at Tin Can. If you are neither a developer nor working with Tin Can, you might not find this post very helpful. You have been warned…
What is content type?
Tin Can is a standard used to send data from one application to another. Along with having various contents, that data has a type. For the statement API, the content type is always application/ json. That’s because the data sent and received uses the json format. For the document APIs, the content type will vary. You can send Word documents, videos, audio, images or anything else via the document API.
The content type is important because it tells the system receiving the data how it should process and present that document. There’s no point trying to process a Word document as a video, or a json object as HTML. If you don’t send the right content type, you’re likely run into problems down the line.
For bookmarking data, I recommend the application/ json content type. The Tin Can specification has special rules for how the LRS processes json documents, allowing you to update part of the document without overwriting changes elsewhere. If you send json content without setting the content type, the LRS won’t follow these rules, and you might run into problems when you try to process the data coming back.
How do I set the content type?
Content type is set as a header in the http request. If you’re using a Tin Can code library (if not, you should be), the library will handle the headers for you. All you need to do is ensure you set the content type configuration parameter when calling the library’s functions. Here’s an example of sending a document to the state API ad application/ json using TinCanJs. There’s also a list of possible content types here.
If you want to know more about using Tin Can in your learning programme, talk to us today to find out how LEO Learning can help.