Product API
API change history- Native REST version * Added option to retrieve a list of items * Response format matched with other APIs * Added productLine to body of message and samples * Corrected storageLoction sample value to be a true numeric value.
/inventory/reservation - POST
Method to reserve stock when it is consumed. This will deduct the available inventory for the related products with the quantity provided in the request. The response will show the updated quantity of each inventory item that was reserved. The status of those items will be true.
If a product does not exist when the reservation method is called this will be highlighted in the response. The related product will not be updated e.g. quantity in response will be zero and status will be unknown. If an item exists and after reservation quanity is zero this will show as status true in the response.
If an item exists but the quantity to reserve is higher than the available quantity, overselling items. The related product will not be updated, the status will be unavailable and the quantity in the response will be the available quantity.
The result of the request will be true if all products were updated successful, if any issue (oversell, unknown products) the result of the request will be false.
requestReference should be the same as passed in the orders message, and is used for logging only.
Request
Request URL
Request headers
-
string
Client specific ID, provided by ModusLink during the onboarding process
-
string
Client specific ID, provided by ModusLink during the onboarding process
-
string
media type used
-
(optional)stringMedia type of the body sent to the API.
Request body
{
"requestReference": "string",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 1,
"storageLocation": "DEMOUS"
}
]
}
{
"type": "object",
"properties": {
"requestReference": {
"type": "string",
"description": "The request reference for the order related to the inventory reservation. Only used for logging purposes."
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is available. This relates to the fulfilment centre."
}
},
"description": "object that holds inventory information per product"
}
}
},
"description": "List of products for which inventory needs to be updated"
}
Responses
200 OK
OK
Representations
{
"result": "true",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 4,
"storageLocation": "3505",
"status": "true"
}
],
"errorCode": "",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "string",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 1,
"storageLocation": "DEMOUS",
"status": "true"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
401 Unauthorized
Invalid authorization
Representations
{
"result": "false",
"inventory": [],
"errorCode": "401",
"message": [
{
"message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription.",
"path": "",
"errorType": "authentication"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "false",
"errorCode": "401",
"message": [
{
"message": "Access denied due to invalid ClientAuthKey or ClientConfigID. Make sure to provide a valid ClientAuthKey and ClientConfigID to access the resource",
"path": "",
"errorType": "authentication"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "string",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 1,
"storageLocation": "DEMOUS",
"status": "true"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
404 Not Found
no data found
Representations
{
"result": "false",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 4,
"storageLocation": "3505"
},
{
"productLine": "MLDEMOUS",
"sku": "10599219",
"quantity": 0,
"storageLocation": "3505"
}
],
"errorCode": "404",
"message": [
{
"message": "Invalid SKU(s)",
"path": "",
"errorType": "Invalid SKU(s)"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "false",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 4,
"storageLocation": "3505",
"status": "true"
},
{
"productLine": "MLDEMOUS",
"sku": "10599219",
"quantity": 0,
"storageLocation": "3505",
"status": "unknown"
}
],
"errorCode": "404",
"message": [
{
"message": "invalid SKU(s)",
"path": "",
"errorType": "invalid SKU(s)"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "false",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 4,
"storageLocation": "3505",
"status": "true"
},
{
"productLine": "MLDEMOUS",
"sku": "10599219",
"quantity": 2,
"storageLocation": "3505",
"status": "unavailable"
}
],
"errorCode": "404",
"message": [
{
"message": "quantity is unavailable",
"path": "",
"errorType": "unavailable quantity"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "string",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 1,
"storageLocation": "DEMOUS",
"status": "true"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
500 Internal Server Error
Server Error
Representations
{
"result": "false",
"inventory": [],
"errorCode": "500",
"message": [
{
"message": "internal server error",
"path": "",
"errorType": "server error"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
{
"result": "string",
"inventory": [
{
"productLine": "MLDEMOUS",
"sku": "10599209",
"quantity": 1,
"storageLocation": "DEMOUS",
"status": "true"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"inventory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productLine": {
"type": "string",
"example": "MLDEMOUS",
"description": "the product line is the logical stock location client config id to reference the same stock.",
"maxLength": 50
},
"sku": {
"type": "string",
"example": "10599209",
"description": "the partnumber of the item",
"maxLength": 18
},
"quantity": {
"type": "number",
"example": 1,
"description": "In case of GET inventory: the available quantity in stock\nIn case of POST inventory/reservation: the qty consumed e.g. order quantity"
},
"storageLocation": {
"type": "string",
"example": "DEMOUS",
"description": "the location where the stock is phsyically available. This relates to the fulfillment center. Will link to the product_line/storage location."
},
"status": {
"type": "string",
"description": "The status of the update for the relevant item. Only applies to output. Not included in request.",
"enum": [
"true",
"unknown",
"unavailable"
]
}
},
"description": "object that holds inventory information per product"
}
},
"errorCode": {
"type": "string",
"description": "no data found"
},
"message": {
"type": "array",
"description": "No data found error",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "",
"description": "A description of the error"
},
"path": {
"type": "string",
"example": "",
"description": "the element which has the error"
},
"errorType": {
"type": "string",
"example": "",
"description": "The type of error"
}
}
}
}
},
"description": "The response when calling API"
}
Code samples
@ECHO OFF
curl -v -X POST "https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation"
-H "ClientConfigId: 114"
-H "ClientAuthKey: 43006300-9E2A-4ED5-A001-126712985994"
-H "Content-Type: application/json"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("ClientConfigId", "114");
client.DefaultRequestHeaders.Add("ClientAuthKey", "43006300-9E2A-4ED5-A001-126712985994");
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation?" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("{body}");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
response = await client.PostAsync(uri, content);
}
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader("ClientConfigId", "114");
request.setHeader("ClientAuthKey", "43006300-9E2A-4ED5-A001-126712985994");
request.setHeader("Content-Type", "application/json");
request.setHeader("Content-Type", "application/json");
request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
};
$.ajax({
url: "https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("ClientConfigId","114");
xhrObj.setRequestHeader("ClientAuthKey","43006300-9E2A-4ED5-A001-126712985994");
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "POST",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation";
NSArray* array = @[
// Request parameters
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"POST"];
// Request headers
[_request setValue:@"114" forHTTPHeaderField:@"ClientConfigId"];
[_request setValue:@"43006300-9E2A-4ED5-A001-126712985994" forHTTPHeaderField:@"ClientAuthKey"];
[_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation');
$url = $request->getUrl();
$headers = array(
// Request headers
'ClientConfigId' => '114',
'ClientAuthKey' => '43006300-9E2A-4ED5-A001-126712985994',
'Content-Type' => 'application/json',
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'ClientConfigId': '114',
'ClientAuthKey': '43006300-9E2A-4ED5-A001-126712985994',
'Content-Type': 'application/json',
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('api-uat.moduslink.com')
conn.request("POST", "/productapi/v1.1/inventory/reservation?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'ClientConfigId': '114',
'ClientAuthKey': '43006300-9E2A-4ED5-A001-126712985994',
'Content-Type': 'application/json',
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('api-uat.moduslink.com')
conn.request("POST", "/productapi/v1.1/inventory/reservation?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://api-uat.moduslink.com/productapi/v1.1/inventory/reservation')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['ClientConfigId'] = '114'
# Request headers
request['ClientAuthKey'] = '43006300-9E2A-4ED5-A001-126712985994'
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body