Using the REST API of ImageVault
In ImageVault 4 we introduced a REST API for the ImageVault Core service. This will show a small example on how to use that.
Javascript
<script type="text/javascript" src="https://imagevault.se/beta/ImageVault/Scripts/lib/jquery-1.6.1.js" ></script> <script type="text/javascript" src="https://imagevault.se/beta/ImageVault/Scripts/lib/json2.js"></script> <script type="text/javascript" src="https://imagevault.se/beta/ImageVault/Scripts/ImageVault.Client.js"></script>
Client
var core = new ImageVault.Client({
authUrl: "https://imagevault.se/beta/ImageVaultIdp/http.issue",
realm: "https://imagevault.se:1234",
username: "demouser",
password: "P@55w0rd!"
});
- authUrl
- This is the url to the Idp endpoint that can issue a ticket to be used with the core calls. Authentication uses federated authentication
- realm
- This is the url to core and also instructs the Idp on who the recipient of the ticket is.
- username/password
- the username and password of the user.
Authentication
API calls to Core
core.json("MediaService/Find", {
Filter: { SearchString: searchString },
Populate: {
MediaFormats: [
//Thumbnail format
{
$type: "ImageVault.Common.Data.ThumbnailFormat,ImageVault.Common",
Effects:[
{$type:"ImageVault.Common.Data.Effects.ResizeEffect, ImageVault.Common",Width:200,Height:200,ResizeMode:'ScaleToFill'}
]
}
]
}
}, function (d) {
alert(JSON.stringify(d));
});
- path
- The service/method to call. Name of the service is the same as the interface (omit the leading I)
- arguments
- the arguments to the service method as a javascript object. If the method takes multiple arguments, wrap them in a single object (.e {arg1:'test',arg2:'test2'} )
- success callback
- The function to call when the service call is done. The argument to the function is the return value of the service method.
