PUT v4/packages/:pkg_sku - Update

Update Package metadata and assets/SKUs associated to a specific package. 

Supported Roles and Authentication Protocols

Type Supported Values
Authentication Protocols API Key
Valid for Roles System to System

API Request

HTTP Verbs and URLs

PUT v4/packages/:pkg_sku

Request Headers

X-VitalSource-API-Key: ABCDEFGHIJKLMNOP
Content-Type: application/json

Request Body

Request

{ 
    "name":"A & M College of Pharmacy Review",
    "description":"",
    "products": [
        { 
            "sku": "1234"
        },
        { 
            "sku": "5678"
        }
    ],
    "library_id":"1",
    "license_rule": {
        "type":"",
        "num_days":"",
        "expiration_date":"2017-01-01"
    },
    "online_license_rule": {
        "type":"",
        "num_days":"",
        "expiration_date":"2017-01-01"
    },
    "list_price": 19.99, # USD
    "in_store": true,
    "in_uk_store: false,
    "in_au_store": false,
    "tags": ["TAG 1","TAG 2"]
}

Element Descriptions

Element Description Required
name The name of the package No
description Optional package description to display to end users No
products {sku} A list of assets or sku identifiers that are needed to create the package. This can be left blank but will create an empty package to be updated later No
list_price The price for the package if necessary No
library_id  he specific Library set up within Connect to specify where the package will live. This must be a LibraryID that was created by the requesting companies API key.  No
 download_license/online_license  Specific elements to specify the license length and type for downloadable and online clients. Must set a specific value No 
 type  Set value for type of license. Options are numdays, absdate, perpetual No
num_days  Number of days from redemption that access is granted  Only if type=numdays
 expiration_date    Only if type=absdate
list_price  The price for the package if necessary  No

 

Request Response

curl -X PUT -H "X-VitalSource-API-Key: ABCDEFGHIJKLMNOP" -H "Content-Type: application/json" -d '{
    "name":"Sample Package",
    "products": [ ":sku" ],
    "description": "Sample description goes here!",
    "list_price": 19.99,
}' "https://api.vitalsource.com/v4/packages/:id"
HTTP Code: 200
{
 "sku": "RACD4MGK32C8",
 "name": "Sample Package",
 "description": "Sample description goes here!",
 "publisher": "Company Name",
 "list_price": 19.99,
 "download_license": {
    "details": "Expires 1 days after registration",
    "duration": "1 days"
 },
 "online_license": {
    "details": "Expires 1 days after registration",
    "duration": "1 days"
 },
 "tags": [],
 "created_on": "2016-03-16T18:49:35Z",
 "updated_on": "2016-03-16T18:49:35Z",
 "products": [
 {
    "isbn": "L-999-70461",
    "vbid": "L-999-70461",
    "fpid": null,
    "isbn13": null,
    "description": "In Dickens's traditional favorite Christmas story, miser Ebenezer Scrooge, who despises Christmas and all who revel in its cheer, is forced to take a hard look at his life of selfishness and greed. On Christmas Eve, the ghost of his business partner Jacob Marley and the Spirits of Christmas Past, Present, and Future break Scrooge's calloused heart and redeem him",
    "publication_date": "1843",
    "author": "Charles Dickens",
    "title": "A Christmas Carol",
    "sort_title": "Christmas Carol",
    "icon_url": "http://covers.vitalbook.com/vbid/L-999-70461/width/120",
    "sampleable": true
 }
 ]
} 
require 'uri'
require 'net/http'

url = URI("https://api.vitalsource.com/v4/packages/:id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::PUT.new(url)
request["x-vitalsource-api-key"] = 'ABCDEFGHIJKLMNOP'
request["content-type"] = 'application/json'
request.body = "{\n \"name\":\"Sample Package\",\n \"products\": [ \"L-999-70461\", \"asdf\" ],\n \"description\": \"Sample description goes here!\",\n \"list_price\": 19.99,\n \"tags\": [\"ENG101\",\"Composition\"]\n}"
response = http.request(request) puts response.read_body
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
    "name":"Sample Package",
    "description": "Sample description goes here!",
    "products": [ "L-999-70461" ],
    "list_price": 19.99,
    "tags": ["ENG101","Composition"]
}');

$request->setRequestUrl('https://api.vitalsource.com/v4/packages/:id');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'content-type' => 'application/json',
  'x-vitalsource-api-key' => 'ABCDEFGHIJKLMNOP',
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?php>
var client = new RestClient("https://api.vitalsource.com/v4/packages/:id");
var request = new RestRequest(Method.PUT);
request.AddHeader("content-type", "application/json");
request.AddHeader("x-vitalsource-api-key", "ABCDEFGHIJKLMNOP");
request.AddParameter("application/json", "{\n \"name\":\"Sample Package\",\n \"products\": [ \"L-999-70461\", \"asdf\" ],\n \"description\": \"Sample description goes here!\",\n \"list_price\": 19.99,\n \"tags\": [\"ENG101\",\"Composition\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var http = require("https");

var options = {
  "method": "PUT",
  "hostname": "api.vitalsource.com",
  "port": null,
  "path": "/v4/packages/:id",
  "headers": {
    "x-vitalsource-api-key": "ABCDEFGHIJKLMNOP",
    "content-type": "application/json",
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ name: 'Sample Package',
  description: 'Sample description goes here!',
  products: [ 'L-999-70461' ],
  list_price: 19.99,
  tags: [ 'ENG101', 'Composition' ] }));
req.end();
import http.client

conn = http.client.HTTPSConnection("api.vitalsource.com")

payload = "{\n \"name\":\"Sample Package\",\n \"products\": [ \"L-999-70461\", \"asdf\" ],\n \"description\": \"Sample description goes here!\",\n \"list_price\": 19.99,\n \"tags\": [\"ENG101\",\"Composition\"]\n}"
headers = { 'x-vitalsource-api-key': "ABCDEFGHIJKLMNOP", 'content-type': "application/json", } conn.request("PUT", "/v4/packages/:id", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"name\":\"Sample Package\",\n \"products\": [ \"L-999-70461\", \"asdf\" ],\n \"description\": \"Sample description goes here!\",\n \"list_price\": 19.99,\n \"tags\": [\"ENG101\",\"Composition\"]\n}");
Request request = new Request.Builder()
  .url("https://api.vitalsource.com/v4/packages/:id")
  .put(body)
  .addHeader("x-vitalsource-api-key", "ABCDEFGHIJKLMNOP")
  .addHeader("content-type", "application/json")
  .build();

Response response = client.newCall(request).execute();
 

Element Descriptions

Element Description
sku The auto-generated SKU for the new package
name The name of the package
description Package description to display to end users
Publisher Name of the company who created the package
list_price The price for the package if necessary
library_id The specific Library set up within Connect to specific where the library where the pacakge will live. This must be a LibraryID that was created by the requesting companies API key.
download_license/online_license Specific elements to specify the license length and type for downloadable and online clients. Must set a specific value.
details Text describing license rules set
duration Number of days of num_days was used, otherwise null
tags An array of tags used to query and identify the package in more detail (could be course code, etc)
created_on Date the package was created
updated_on Date the package was last updated this includes meta data updates or items being added to a package
products {sku} A list of assets or sku identifiers and meta data about the items of a package

Specific error codes for this endpoint

403: Permission Denied. Your API Key must have publisher permissions to perform this request. Contact your rep for assistance.
422: Invalid SKU(s) (<sku-list>)
422: Name can't be blank
422: Sku can't be blank
422: License rule can't be blank
422: Online license rule can't be blank
422: Library is not acceptable. Log-in to VitalSource Manage to create/find your Library ID
)

See our full list of error codes and messages.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.