Import of contracts

You use the POST operation on the api/sam/contracts/import element to import contracts from a csv file

An icon representing a user. You must have the Manage Software Classification permission to perform this task.

Table 1. Operation descriptions

The table consists of two columns and 14 body rows.

Operation details Description
Operation /api/sam/contracts/import
Purpose Uploads the contents of the csv file with contract definitions
HTTP method POST
Resource URI https://server_host_name:port_number/api/sam/contracts/import
URL link relation n/a
URI query parameters For a list of applicable query parameters, see: Query parameters.
Request headers
Header
Accept-Language (optional)
Values
en-US, …

Used to negotiate the language of the response. If this header is not specified, the content is returned in the server language.

Header
Content-Type
Values
multipart/form-data
Request payload Contract definitions as form-encoded data specified as a file attachment.
Request Content-Type multipart/form-data
Response headers
Header
Content-Type
Values
Application/json

Specifies the content type of the response.

Header
Content-Language
Values
en-US, …

Specifies the language of the response content. If this header is not specified, the content is returned in the server language.

Response payload Status of imported elements
Response Content-Type Application/json
Normal HTTP response codes
  • 200 – No content
Error HTTP response codes
  • 400 – "Bad Request" if a query parameter contains errors or is missing
  • 401 – "Unauthorized" if the user is not authorized to perform the operation

Message body excludes an error message with details.

Query parameters

Use the upload[contracts] query parameter to specify the path to the csv file with contracts.
Table 2. Query parameters for specifying the path to the csv file with contracts

The table consists of four columns and two rows.

Parameter Description Required Value
upload[contracts] Path to the csv file with contracts Yes String

Example HTTP conversation

Request header
Content-Type: multipart/form-data;
Request
POST /api/sam/contracts/import?token=a2279dc218ecd1f12a5e2fc1b5d77a4e6fec6598
Contract Name,Software Names,Computer Group Name,Seats,Acquisition Cost,
Maintenance Cost,Entitlement Start,Entitlement End,Maintenance Start,
Maintenance End,custStrcon1,"IBM Software Assembly Toolkit,
License Metric Tool 7,License Metric Tool 9.0",All Computers,
10,10.0,5.0,2015-04-23,2015-05-30,2015-04-23,2015-05-30,con2,
BigFix Inventory, All Computers,0,1.0,2.0,2015-04-23,,,, 
Response header
HTTP/1.1 200 OK
Content-Type: application/json
Response
{
	"status":[{
		"type":"CONTRACTS",
		"description":{
			"contract_name":"con1",
			"software_names":"IBM Software Assembly Toolkit,
			License Metric Tool 7,
			License Metric Tool 9.0",
			"user_name":"admin",
			"access_computer_group_name":"All Computers",
			"computer_group_name":"All Computers",
			"seats":"10",
			"acquisition_cost":"10.0",
			"annual_maintenance_cost":"5.0",
			"entitlement_start":"2015-04-23",
			"entitlement_end":"2015-05-30",
			"maintenance_start":"2015-04-23",
			"maintenance_end":"2015-05-30",
			"custom_fields":{
				"custStr":null
			}
		},
		"actions":[{
			"error":"",
			"status":"SUCCESS",
			"type":"ADD"
		}]
	},{
		"type":"CONTRACTS",
		"description":{
			"contract_name":"con2",
			"software_names":"BigFix Inventory",
			"user_name":"admin",
			"access_computer_group_name":"All Computers",
			"computer_group_name":"All Computers",
			"seats":null,
			"acquisition_cost":"1.0",
			"annual_maintenance_cost":"2.0",
			"entitlement_start":"2015-04-23",
			"entitlement_end":null,
			"maintenance_start":null,
			"maintenance_end":null,
			"custom_fields":{
				"custStr":null
			}
		},
		"actions":[{
			"error":"",
			"status":"SKIPPED",
			"type":"ADD"
		}]
	}]
}