Purchase API
API change history- Removed TimeZone
- Decreased RequestReference from max length of 50 to max length of 25.
- Text corrections in descriptions
- modified statuses - goodsreceived and goodspartiallyreceived
Create Purchase Order
Create a new purchase order.
Additional information and instructions.
Date-time format
The date-time format used in request and response is UTC using the ISO 8601 format :
- yyyy-mm-ddThh:mm:ssZ, e.g. 2018-12-19T15:58:00Z
All date-time values should follow this format and should have UTC time without offset.
Example; A pruchase order is posted from the Netherlands where the timezone is UTC+1
. If the local timestamp would be 2018-12-19T15:58:00+01:00
the value provided would be the UTC time, 2018-12-19T14:58:00Z
Multi-site receiving:
multiple CCID’s
In case receiving is done from multiple locations e.g. different regions, ModusLink will provide the client with multiple CCID’s. One for each location/region.
e.g. receiving in the Netherlands and Singapore
In this case 2 CCID’s would be provided. When making a call to the API the appropriate CCID would have to be provided.
Request
Request URL
Request headers
-
string
Client specific ID, provided by ModusLink during the onboarding process
-
string
Client specific authentication key, provided by ModusLink during the onboarding process.
-
(optional)stringMedia type of the body sent to the API.
Request body
{
"clientRequest": {
"requestHeader": {
"externalMessageReference": "API_DEMOUS_PO_1",
"client": "MLDEMOUS",
"requestReference": "API_DEMOUS_PO_1",
"dateTimeSent": "2019-02-06T00:00:00Z"
},
"order": {
"custReference": "1",
"note": [
{
"noteType": "F01",
"value": "Header Test Note"
}
]
},
"item": [
{
"itemId": "1",
"sku": "503001",
"clientItemRef": "101",
"quantity": {
"uom": "EA",
"value": "1"
},
"itemDeliveryDate":"2019-02-11",
"note": [
{
"noteType": "F01",
"value": "Item Test Note"
}
]
}
]
}
}
{
"type": "object",
"properties": {
"requestHeader": {
"type": "object",
"required": [
"externalMessageReference",
"requestReference"
],
"properties": {
"requestType": {
"type": "string",
"description": "Not in request, Will be available only in response. Describes the type of request e.g. PO"
},
"requestStatus": {
"type": "string",
"description": "Not in request. Will be available only in response. The current status of the request.\n - created: Message technically valid and created in Order Management System\n - duplicate: duplicate message reference, request ignored\n - confirmed: message received and successfully loaded in ERP fulfillment system, orderId (POnr) populated\n - cancelled: PO cancelled. Not supported, reserved for possible future use\n - goodspartiallyreceived: Purchase Order partially delivered or underdelivered\n - goodsreceived: Purchase Order fully delivered or overdelivered",
"enum": [
"created",
"duplicate",
"confirmed",
"cancelled",
"goodspartiallyreceived",
"goodsreceived"
]
},
"externalMessageReference": {
"type": "string",
"description": "REQUIRED in POST. Unique client purchase order reference. Duplicates will NOT be rejected at ML order system. In response (GET) this will show in the requestControl, not in the requestHeader.",
"maxLength": 50
},
"client": {
"type": "string",
"description": "REQUIRED. Client Name, to be provided by ModusLink as part of onboarding ",
"maxLength": 40
},
"requestReference": {
"type": "string",
"description": "REQUIRED. Unique client purchase order reference. Usually same as externalMessageReference, can be different. Duplicates will be rejected in ML order system.",
"maxLength": 25
},
"dateTimeSent": {
"type": "string",
"format": "date-time",
"description": "Date passed in the POST for purchase order. format yyyy-mm-ddT00:00:00Z"
},
"dateTimeCreated": {
"type": "string",
"format": "date-time",
"description": "Only in response. Date purchase order was created in our Order Management System. format yyyy-mm-ddT00:00:00Z "
},
"dateTimeConfirmed": {
"type": "string",
"format": "date-time",
"description": "Only in response. Date purchase order was created and confirmed in our BackOffice ERP system. format yyyy-mm-ddT00:00:00Z"
},
"dateTimeGoodsReceived": {
"type": "string",
"format": "date-time",
"description": "Only in response. Date of Purchase Order (last) Goods Delivery booking in our BackOffice ERP system . format yyyy-mm-ddT00:00:00Z "
}
},
"description": "Provides information to create/about a new purchase order"
},
"order": {
"type": "object",
"properties": {
"orderId": {
"type": "string",
"description": "In response only. The orderId in the Fulfilment system (SAP)"
},
"custReference": {
"type": "string",
"description": "Customer Reference for Purchase Order"
},
"status": {
"type": "string",
"description": "In response only. current status of the purchase order in the fulfilment system",
"enum": [
"created",
"duplicate",
"confirmed",
"goodsreceived",
"goodspartiallyReceived",
"cancelled"
]
},
"dateTimeConfirmed": {
"type": "string",
"format": "date-time",
"description": "In response only. The date the purchase order was confirmed in our fulfillment. system format yyyy-mm-ddT00:00:00Z "
},
"note": {
"type": "array",
"items": {
"type": "object",
"required": [
"noteType",
"value"
],
"properties": {
"noteType": {
"type": "string",
"description": "Type of the notes",
"maxLength": 4
},
"value": {
"type": "string",
"description": "Value of the notes",
"maxLength": 132
}
},
"description": "Notes Info:\nCan be used to pass information you would like to have included in GET detail. These do not drive functionality and are not available to warehouse operators. E.g. pass name=value pairs in F01 note in a POST to be echoed back on GET.\n\n* F01 - general note\n* F05 - Terms of Delivery\n* F06 - Shipping instructions item"
}
}
},
"description": "REQUIRED. The purchase order object contains purchase order related data"
},
"item": {
"type": "array",
"items": {
"type": "object",
"required": [
"itemId",
"quantity",
"sku"
],
"properties": {
"itemId": {
"type": "string",
"description": "REQUIRED: Can be client specific value, numeric only. Or line number should be item sequential number 1,2,3.."
},
"clientItemRef": {
"type": "string",
"description": "Purchase Order line number from client e.g. client line reference for the item.",
"maxLength": 5
},
"sku": {
"type": "string",
"description": "REQUIRED. Item sales product number/partnumber",
"maxLength": 18
},
"quantity": {
"properties": {
"uom": {
"type": "string",
"description": "REQUIRED. Item unit of measure (EA, BX, CS)",
"default": "EA",
"enum": [
"EA",
"BX",
"CS"
]
},
"value": {
"type": "string",
"description": "REQUIRED. Numerical value"
}
},
"description": "REQUIRED. Item Quantity info"
},
"itemDeliveryDate": {
"type": "string",
"format": "date",
"description": "expected delivery date of purchase order item"
},
"notes": {
"type": "array",
"items": {
"type": "object",
"required": [
"noteType",
"value"
],
"properties": {
"noteType": {
"type": "string",
"description": "Type of the notes",
"maxLength": 4
},
"value": {
"type": "string",
"description": "Value of the notes",
"maxLength": 132
}
},
"description": "Notes Info:\nCan be used to pass information you would like to have included in GET detail. These do not drive functionality and are not available to warehouse operators. E.g. pass name=value pairs in F01 note in a POST to be echoed back on GET.\n\n* F01 - general note\n* F05 - Terms of Delivery\n* F06 - Shipping instructions item"
}
}
},
"description": "Items are REQUIRED. holds purchase Order line/item info, replicate for each item"
}
}
},
"description": "Provides information to create a new purchase order",
"example": "{\n \"clientRequest\": {\n \"requestHeader\": {\n \"externalMessageReference\": \"API_DEMOUS_PO_1\",\n \"client\": \"MLDEMOUS\",\n \"requestReference\": \"API_DEMOUS_PO_1\",\n \"dateTimeSent\": \"2019-02-06T00:00:00Z\"\n },\n \"order\": {\n \"custReference\": \"1\",\n \"note\": [\n {\n \"noteType\": \"F01\",\n \"value\": \"Header Test Note\"\n }\n ]\n },\n \"item\": [\n {\n \"itemId\": \"1\",\n \"sku\": \"503001\",\n \"clientItemRef\": \"101\",\n \"quantity\": {\n \"uom\": \"EA\",\n \"value\": \"1\"\n },\n \"itemDeliveryDate\":\"2019-02-11\",\n \"note\": [\n {\n \"noteType\": \"F01\",\n \"value\": \"Item Test Note\"\n }\n ]\n }\n ]\n }\n}"
}
Responses
202 Accepted
Transaction was received and passed Schema validation
Representations
{
"result": "true",
"requestId": "3201413",
"requestReference": "API_DEMOUS_1",
"externalMessageReference": "API_DEMOUS_1",
"links": [
{
"href": "/purchaseapi/V1/orders/3201413",
"rel": "orders",
"method": "GET",
"description": "Request of type purchase orders is returned"
}
],
"errorCode": "",
"message": [
{}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "string",
"requestReference": "string",
"externalMessageReference": "string",
"links": [
{
"href": "string",
"rel": "string",
"method": "string",
"description": "string"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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"
}
400 Bad Request
Transaction was received and failed JSON validation
Representations
{
"result": "false",
"requestId": "",
"requestReference": "API_DEMOUS_1",
"externalMessageReference": "API_DEMOUS_1",
"links": [],
"errorCode": "400",
"message": [
{
"message": "The request is not in valid JSON format",
"path": "",
"errorType": "invalid format"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "string",
"requestReference": "string",
"externalMessageReference": "string",
"links": [
{
"href": "string",
"rel": "string",
"method": "string",
"description": "string"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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 authentication
Representations
{
"result": "false",
"requestId": "",
"requestReference": "",
"externalMessageReference": "",
"links": [],
"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"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "string",
"requestReference": "string",
"externalMessageReference": "string",
"links": [
{
"href": "string",
"rel": "string",
"method": "string",
"description": "string"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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"
}
409 Conflict
Duplicate Transaction
Representations
{
"result": "false",
"requestId": "",
"requestReference": "API_DEMOUS_1",
"externalMessageReference": "API_DEMOUS_1",
"links": [],
"errorCode": "409",
"message": [
{
"message": "This is a duplicate purchase order",
"path": "#/clientRequest.requestHeader.requestReference",
"errorType": "duplicate"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "string",
"requestReference": "string",
"externalMessageReference": "string",
"links": [
{
"href": "string",
"rel": "string",
"method": "string",
"description": "string"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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"
}
412 Precondition Failed
Transaction was received and failed Schema validation
Representations
{
"result": "false",
"requestId": "",
"requestReference": "API_DEMOUS_1",
"externalMessageReference": "API_DEMOUS_1",
"links": [],
"errorCode": "412",
"message": [
{
"message": "Value \"capture\" is not defined in enum.",
"path": "#/clientRequest.order.incoTerms1",
"errorType": "NotInEnumeration"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "string",
"requestReference": "string",
"externalMessageReference": "string",
"links": [
{
"href": "string",
"rel": "string",
"method": "string",
"description": "string"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "",
"requestReference": "",
"externalMessageReference": "",
"links": [],
"errorCode": "500",
"message": [
{
"message": "internal server error",
"path": "",
"errorType": "server error"
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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",
"requestId": "string",
"requestReference": "string",
"externalMessageReference": "string",
"links": [
{
"href": "string",
"rel": "string",
"method": "string",
"description": "string"
}
],
"errorCode": "string",
"message": [
{
"message": "",
"path": "",
"errorType": ""
}
]
}
{
"type": "object",
"properties": {
"result": {
"type": "string",
"description": "result of transaction"
},
"requestId": {
"type": "string"
},
"requestReference": {
"type": "string"
},
"externalMessageReference": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string",
"description": "Link to the purchase order created. Only if result = true"
},
"rel": {
"type": "string",
"description": "relationship. Note in relation to the POST purchase orders, the creation of purchase orders is asynchronous, so the purchase order will not be available immediately."
},
"method": {
"type": "string",
"description": "The method applicable for the link"
},
"description": {
"type": "string",
"description": "Description of the link provided"
}
},
"description": "List of available links"
}
},
"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/purchaseapi/v1/orders"
-H "ClientConfigId: 1077"
-H "ClientAuthKey: 5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D"
-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", "1077");
client.DefaultRequestHeaders.Add("ClientAuthKey", "5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D");
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://api-uat.moduslink.com/purchaseapi/v1/orders?" + 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/purchaseapi/v1/orders");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader("ClientConfigId", "1077");
request.setHeader("ClientAuthKey", "5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D");
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/purchaseapi/v1/orders?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("ClientConfigId","1077");
xhrObj.setRequestHeader("ClientAuthKey","5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D");
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/purchaseapi/v1/orders";
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:@"1077" forHTTPHeaderField:@"ClientConfigId"];
[_request setValue:@"5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D" forHTTPHeaderField:@"ClientAuthKey"];
[_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/purchaseapi/v1/orders');
$url = $request->getUrl();
$headers = array(
// Request headers
'ClientConfigId' => '1077',
'ClientAuthKey' => '5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D',
'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': '1077',
'ClientAuthKey': '5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D',
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('api-uat.moduslink.com')
conn.request("POST", "/purchaseapi/v1/orders?%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': '1077',
'ClientAuthKey': '5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D',
'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", "/purchaseapi/v1/orders?%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/purchaseapi/v1/orders')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['ClientConfigId'] = '1077'
# Request headers
request['ClientAuthKey'] = '5C0FDFDE-B714-42AE-BF4B-EB5E1409C53D'
# 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