Products
API change historyList stores, categories, and items configured in the Direct Scale Commission Engine.
Get Item by SKU
Retrieves an Item based on a valid Item Stock Keeping Unit (SKU).
You can get the Request Parameters at these calls:
sku
- Get Item by Id
- Get Items
- Get Items by Filter
CurrencyCode
- Get Regions displays the country/state codes of the warehouses. If you are concerned about having the proper CurrencyCode, then this will allow you to know what region warehouse support team to call to get the confirmed CurrencyCode.
LanguageCode
- Get Item by Id
- Get Items
- Get Items by Filter
Note:
The full Image path for the item is on the Disco application server, at this URL:
https://
The "Discounts" array is a collection of all the prices. The "Type" field is an enumeration, "Discount, Price, RewardCost". So, if it's "0", it's the discounted price. If it's "1", it's the original price. If it's "2", it's the Reward Point cost.
What's happening here is that you have Type => 1 (Price) and Type => 0 (Discount), so you can show both prices (with a slash through the full price).
Request
Request URL
Request parameters
-
string
The SKU of the Item to retrieve.
-
(optional)string
The 3-character ISO currency code indicating pricing to be returned.
-
(optional)string
The 2-character ISO language code indicating language of translations.
Request headers
Request body
Responses
200 OK
Returns a valid Item object.
Representations
{
"Id": 1,
"Sku": "DRTSCL",
"KitLevel": 0,
"Category": {
"Id": 1,
"Name": "Test Category",
"Description": "Test Category",
"DisplayIndex": 0,
"ImageUrl": null,
"ParentId": 0,
"ProductLineId": 0,
"ShortDescription": "Test Category",
"StoreIds": [],
"HasChildren": false
},
"ChargeShipping": true,
"Disabled": false,
"Height": 0,
"Image": "/testitem.jpg",
"Length": 0,
"LengthUnitOfMeasure": "cm",
"ManufacturerPartNum": "",
"OutOfStockStatus": 1,
"PackCount": 0,
"PackageGroupId": 1,
"PreferedVendorId": 0,
"SortOrder": 0,
"TaxClassId": 0,
"ProductClass": 1,
"TrackStock": true,
"UnitOfMeasure": "",
"Upc": "",
"Weight": 1,
"WeightUnitOfMeasure": "kg",
"Width": 0,
"FlagCancer": false,
"FlagBirthDefects": false,
"HasKitGroups": false,
"HasOptions": true,
"HsCode": "",
"Custom": {
"ItemId": 0,
"Field1": "",
"Field2": "",
"Field3": "",
"Field4": "",
"Field5": ""
},
"FastStart": {
"Gen1": 0,
"Gen2": 0,
"Gen3": 0,
"Gen4": 0,
"Gen5": 0,
"Gen6": 0,
"Gen7": 0,
"Gen8": 0,
"Gen9": 0,
"Gen10": 0
},
"Images": [
{
"Description": "/testitem.jpg",
"Path": "/testitem.jpg"
}
],
"Languages": [
{
"Description": "",
"LanguageCode": "ab",
"ProductName": "",
"SeoKeywords": "",
"Specifications": ""
},
{
"Description": "<p>Test Item (desc)</p>",
"LanguageCode": "en",
"ProductName": "Test Item",
"SeoKeywords": "",
"Specifications": "<p>Test Item (specs)</p>"
}
],
"Options": [
{
"OptionId": 3,
"Option": "Color",
"OptionType": 1,
"Values": [
{
"Option": "Blue",
"SkuExt": "-B"
},
{
"Option": "Green",
"SkuExt": "-G"
},
{
"Option": "Red",
"SkuExt": "-R"
}
]
},
{
"OptionId": 4,
"Option": "Size",
"OptionType": 1,
"Values": [
{
"Option": "Lage",
"SkuExt": "-L"
},
{
"Option": "Medium",
"SkuExt": "-M"
},
{
"Option": "Small",
"SkuExt": "-S"
}
]
}
],
"OptionsMap": [
{
"Key": "Red|Small",
"Checked": true,
"ItemId": 154,
"Image": "",
"ExtSku": "-R-S",
"StockLevels": []
},
{
"Key": "Red|Medium",
"Checked": true,
"ItemId": 155,
"Image": "",
"ExtSku": "-R-M",
"StockLevels": []
},
{
"Key": "Red|Lage",
"Checked": true,
"ItemId": 156,
"Image": "",
"ExtSku": "-R-L",
"StockLevels": []
},
{
"Key": "Green|Small",
"Checked": true,
"ItemId": 157,
"Image": "",
"ExtSku": "-G-S",
"StockLevels": []
},
{
"Key": "Green|Medium",
"Checked": true,
"ItemId": 158,
"Image": "",
"ExtSku": "-G-M",
"StockLevels": []
},
{
"Key": "Green|Lage",
"Checked": true,
"ItemId": 159,
"Image": "",
"ExtSku": "-G-L",
"StockLevels": []
},
{
"Key": "Blue|Small",
"Checked": true,
"ItemId": 160,
"Image": "",
"ExtSku": "-B-S",
"StockLevels": []
},
{
"Key": "Blue|Medium",
"Checked": true,
"ItemId": 161,
"Image": "",
"ExtSku": "-B-M",
"StockLevels": []
},
{
"Key": "Blue|Lage",
"Checked": true,
"ItemId": 162,
"Image": "",
"ExtSku": "-B-L",
"StockLevels": []
}
],
"Discounts": [
{
"Id": 175,
"Bonus": null,
"End": "9998-12-31T00:00:00Z",
"Price": 10,
"PriceCurrency": "USD",
"Cv": 5,
"Qv": 4,
"RewardPointsEarned": 0,
"Start": "2000-01-01T00:00:00Z",
"Type": 1,
"Stores": [
1,
2,
3,
4,
5
],
"OrderType": [
1,
2
],
"PriceGroups": [
1,
2
],
"Regions": [
1
]
}
],
"KitGroups": [
{
"Name": "Kit Group 1",
"Items": [
{
"ItemId": 22,
"Name": "Kit 1 Item 1",
"Quantity": 2
},
{
"ItemId": 19,
"Name": "Kit 1 Item 2",
"Quantity": 1
},
{
"ItemId": 97,
"Name": "Kit 1 Item 3",
"Quantity": 2
}
]
},
{
"Name": "Kit Group 2",
"Items": [
{
"ItemId": 20,
"Name": "Kit 2 Item 1",
"Quantity": 1
},
{
"ItemId": 21,
"Name": "Kit 2 Item 2",
"Quantity": 3
}
]
}
],
"BillOfMaterials": [
{
"ItemId": 19,
"Name": "BOM Item 1",
"Quantity": 1
},
{
"ItemId": 23,
"Name": "BOM Item 2",
"Quantity": 1
}
],
"StockLevels": [
{
"WarehouseId": 1,
"ItemId": 1,
"Avaliable": 100,
"Committed": 100,
"OnHand": 200,
"OnOrder": 0,
"OutOfStock": false,
"TrackStock": 1
}
]
}
{
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Sku": {
"type": "string"
},
"KitLevel": {
"type": "integer"
},
"Category": {
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Description": {
"type": "string"
},
"DisplayIndex": {
"type": "integer"
},
"ImageUrl": {},
"ParentId": {
"type": "integer"
},
"ProductLineId": {
"type": "integer"
},
"ShortDescription": {
"type": "string"
},
"StoreIds": {
"type": "array"
},
"HasChildren": {
"type": "boolean"
}
}
},
"ChargeShipping": {
"type": "boolean"
},
"Disabled": {
"type": "boolean"
},
"Height": {
"type": "integer"
},
"Image": {
"type": "string"
},
"Length": {
"type": "integer"
},
"LengthUnitOfMeasure": {
"type": "string"
},
"ManufacturerPartNum": {
"type": "string"
},
"OutOfStockStatus": {
"type": "integer"
},
"PackCount": {
"type": "integer"
},
"PackageGroupId": {
"type": "integer"
},
"PreferedVendorId": {
"type": "integer"
},
"SortOrder": {
"type": "integer"
},
"TaxClassId": {
"type": "integer"
},
"ProductClass": {
"type": "integer"
},
"TrackStock": {
"type": "boolean"
},
"UnitOfMeasure": {
"type": "string"
},
"Upc": {
"type": "string"
},
"Weight": {
"type": "integer"
},
"WeightUnitOfMeasure": {
"type": "string"
},
"Width": {
"type": "integer"
},
"FlagCancer": {
"type": "boolean"
},
"FlagBirthDefects": {
"type": "boolean"
},
"HasKitGroups": {
"type": "boolean"
},
"HasOptions": {
"type": "boolean"
},
"HsCode": {
"type": "string"
},
"Custom": {
"type": "object",
"properties": {
"ItemId": {
"type": "integer"
},
"Field1": {
"type": "string"
},
"Field2": {
"type": "string"
},
"Field3": {
"type": "string"
},
"Field4": {
"type": "string"
},
"Field5": {
"type": "string"
}
}
},
"FastStart": {
"type": "object",
"properties": {
"Gen1": {
"type": "integer"
},
"Gen2": {
"type": "integer"
},
"Gen3": {
"type": "integer"
},
"Gen4": {
"type": "integer"
},
"Gen5": {
"type": "integer"
},
"Gen6": {
"type": "integer"
},
"Gen7": {
"type": "integer"
},
"Gen8": {
"type": "integer"
},
"Gen9": {
"type": "integer"
},
"Gen10": {
"type": "integer"
}
}
},
"Images": {
"type": "array",
"items": {
"required": [
"Description",
"Path"
],
"type": "object",
"properties": {
"Description": {
"type": "string"
},
"Path": {
"type": "string"
}
}
}
},
"Languages": {
"type": "array",
"items": {
"required": [
"Description",
"LanguageCode",
"ProductName",
"SeoKeywords",
"Specifications"
],
"type": "object",
"properties": {
"Description": {
"type": "string"
},
"LanguageCode": {
"type": "string"
},
"ProductName": {
"type": "string"
},
"SeoKeywords": {
"type": "string"
},
"Specifications": {
"type": "string"
}
}
}
},
"Options": {
"type": "array",
"items": {
"required": [
"OptionId",
"Option",
"OptionType",
"Values"
],
"type": "object",
"properties": {
"OptionId": {
"type": "integer"
},
"Option": {
"type": "string"
},
"OptionType": {
"type": "integer"
},
"Values": {
"type": "array",
"items": {
"required": [
"Option",
"SkuExt"
],
"type": "object",
"properties": {
"Option": {
"type": "string"
},
"SkuExt": {
"type": "string"
}
}
}
}
}
}
},
"OptionsMap": {
"type": "array",
"items": {
"required": [
"Key",
"Checked",
"ItemId",
"Image",
"ExtSku",
"StockLevels"
],
"type": "object",
"properties": {
"Key": {
"type": "string"
},
"Checked": {
"type": "boolean"
},
"ItemId": {
"type": "integer"
},
"Image": {
"type": "string"
},
"ExtSku": {
"type": "string"
},
"StockLevels": {
"type": "array"
}
}
}
},
"Discounts": {
"type": "array",
"items": {
"required": [
"Id",
"Bonus",
"End",
"Price",
"PriceCurrency",
"Cv",
"Qv",
"RewardPointsEarned",
"Start",
"Type",
"Stores",
"OrderType",
"PriceGroups",
"Regions"
],
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Bonus": {},
"End": {
"type": "string"
},
"Price": {
"type": "integer"
},
"PriceCurrency": {
"type": "string"
},
"Cv": {
"type": "integer"
},
"Qv": {
"type": "integer"
},
"RewardPointsEarned": {
"type": "integer"
},
"Start": {
"type": "string"
},
"Type": {
"type": "integer"
},
"Stores": {
"type": "array",
"items": {
"type": "integer"
}
},
"OrderType": {
"type": "array",
"items": {
"type": "integer"
}
},
"PriceGroups": {
"type": "array",
"items": {
"type": "integer"
}
},
"Regions": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
},
"KitGroups": {
"type": "array",
"items": {
"required": [
"Name",
"Items"
],
"type": "object",
"properties": {
"Name": {
"type": "string"
},
"Items": {
"type": "array",
"items": {
"required": [
"ItemId",
"Name",
"Quantity"
],
"type": "object",
"properties": {
"ItemId": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Quantity": {
"type": "integer"
}
}
}
}
}
}
},
"BillOfMaterials": {
"type": "array",
"items": {
"required": [
"ItemId",
"Name",
"Quantity"
],
"type": "object",
"properties": {
"ItemId": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Quantity": {
"type": "integer"
}
}
}
},
"StockLevels": {
"type": "array",
"items": {
"required": [
"WarehouseId",
"ItemId",
"Avaliable",
"Committed",
"OnHand",
"OnOrder",
"OutOfStock",
"TrackStock"
],
"type": "object",
"properties": {
"WarehouseId": {
"type": "integer"
},
"ItemId": {
"type": "integer"
},
"Avaliable": {
"type": "integer"
},
"Committed": {
"type": "integer"
},
"OnHand": {
"type": "integer"
},
"OnOrder": {
"type": "integer"
},
"OutOfStock": {
"type": "boolean"
},
"TrackStock": {
"type": "integer"
}
}
}
}
},
"example": {
"Id": 1,
"Sku": "DRTSCL",
"KitLevel": 0,
"Category": {
"Id": 1,
"Name": "Test Category",
"Description": "Test Category",
"DisplayIndex": 0,
"ImageUrl": null,
"ParentId": 0,
"ProductLineId": 0,
"ShortDescription": "Test Category",
"StoreIds": [],
"HasChildren": false
},
"ChargeShipping": true,
"Disabled": false,
"Height": 0,
"Image": "/testitem.jpg",
"Length": 0,
"LengthUnitOfMeasure": "cm",
"ManufacturerPartNum": "",
"OutOfStockStatus": 1,
"PackCount": 0,
"PackageGroupId": 1,
"PreferedVendorId": 0,
"SortOrder": 0,
"TaxClassId": 0,
"ProductClass": 1,
"TrackStock": true,
"UnitOfMeasure": "",
"Upc": "",
"Weight": 1,
"WeightUnitOfMeasure": "kg",
"Width": 0,
"FlagCancer": false,
"FlagBirthDefects": false,
"HasKitGroups": false,
"HasOptions": true,
"HsCode": "",
"Custom": {
"ItemId": 0,
"Field1": "",
"Field2": "",
"Field3": "",
"Field4": "",
"Field5": ""
},
"FastStart": {
"Gen1": 0,
"Gen2": 0,
"Gen3": 0,
"Gen4": 0,
"Gen5": 0,
"Gen6": 0,
"Gen7": 0,
"Gen8": 0,
"Gen9": 0,
"Gen10": 0
},
"Images": [
{
"Description": "/testitem.jpg",
"Path": "/testitem.jpg"
}
],
"Languages": [
{
"Description": "",
"LanguageCode": "ab",
"ProductName": "",
"SeoKeywords": "",
"Specifications": ""
},
{
"Description": "<p>Test Item (desc)</p>",
"LanguageCode": "en",
"ProductName": "Test Item",
"SeoKeywords": "",
"Specifications": "<p>Test Item (specs)</p>"
}
],
"Options": [
{
"OptionId": 3,
"Option": "Color",
"OptionType": 1,
"Values": [
{
"Option": "Blue",
"SkuExt": "-B"
},
{
"Option": "Green",
"SkuExt": "-G"
},
{
"Option": "Red",
"SkuExt": "-R"
}
]
},
{
"OptionId": 4,
"Option": "Size",
"OptionType": 1,
"Values": [
{
"Option": "Lage",
"SkuExt": "-L"
},
{
"Option": "Medium",
"SkuExt": "-M"
},
{
"Option": "Small",
"SkuExt": "-S"
}
]
}
],
"OptionsMap": [
{
"Key": "Red|Small",
"Checked": true,
"ItemId": 154,
"Image": "",
"ExtSku": "-R-S",
"StockLevels": []
},
{
"Key": "Red|Medium",
"Checked": true,
"ItemId": 155,
"Image": "",
"ExtSku": "-R-M",
"StockLevels": []
},
{
"Key": "Red|Lage",
"Checked": true,
"ItemId": 156,
"Image": "",
"ExtSku": "-R-L",
"StockLevels": []
},
{
"Key": "Green|Small",
"Checked": true,
"ItemId": 157,
"Image": "",
"ExtSku": "-G-S",
"StockLevels": []
},
{
"Key": "Green|Medium",
"Checked": true,
"ItemId": 158,
"Image": "",
"ExtSku": "-G-M",
"StockLevels": []
},
{
"Key": "Green|Lage",
"Checked": true,
"ItemId": 159,
"Image": "",
"ExtSku": "-G-L",
"StockLevels": []
},
{
"Key": "Blue|Small",
"Checked": true,
"ItemId": 160,
"Image": "",
"ExtSku": "-B-S",
"StockLevels": []
},
{
"Key": "Blue|Medium",
"Checked": true,
"ItemId": 161,
"Image": "",
"ExtSku": "-B-M",
"StockLevels": []
},
{
"Key": "Blue|Lage",
"Checked": true,
"ItemId": 162,
"Image": "",
"ExtSku": "-B-L",
"StockLevels": []
}
],
"Discounts": [
{
"Id": 175,
"Bonus": null,
"End": "9998-12-31T00:00:00Z",
"Price": 10,
"PriceCurrency": "USD",
"Cv": 5,
"Qv": 4,
"RewardPointsEarned": 0,
"Start": "2000-01-01T00:00:00Z",
"Type": 1,
"Stores": [
1,
2,
3,
4,
5
],
"OrderType": [
1,
2
],
"PriceGroups": [
1,
2
],
"Regions": [
1
]
}
],
"KitGroups": [
{
"Name": "Kit Group 1",
"Items": [
{
"ItemId": 22,
"Name": "Kit 1 Item 1",
"Quantity": 2
},
{
"ItemId": 19,
"Name": "Kit 1 Item 2",
"Quantity": 1
},
{
"ItemId": 97,
"Name": "Kit 1 Item 3",
"Quantity": 2
}
]
},
{
"Name": "Kit Group 2",
"Items": [
{
"ItemId": 20,
"Name": "Kit 2 Item 1",
"Quantity": 1
},
{
"ItemId": 21,
"Name": "Kit 2 Item 2",
"Quantity": 3
}
]
}
],
"BillOfMaterials": [
{
"ItemId": 19,
"Name": "BOM Item 1",
"Quantity": 1
},
{
"ItemId": 23,
"Name": "BOM Item 2",
"Quantity": 1
}
],
"StockLevels": [
{
"WarehouseId": 1,
"ItemId": 1,
"Avaliable": 100,
"Committed": 100,
"OnHand": 200,
"OnOrder": 0,
"OutOfStock": false,
"TrackStock": 1
}
]
}
}
404 Not Found
An Item with the given Item SKU was not found.
500 Internal Server Error
Something went wrong... Here are some possible reasons for this error:
- Is the model being sent to the API incorrect?
- Did you forget a required field?
- Is the API marked as deprecated, and the date has expired?
If the answer is "No" to all of these questions, DirectScale could be experiencing technical difficulties. Please contact your DirectScale representative if the issue persists.
Code samples
@ECHO OFF
curl -v -X GET "https://dsapi-stage.directscale.com/v1/products/item/sku/{sku}?CurrencyCode=usd&LanguageCode=en"
-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("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request parameters
queryString["CurrencyCode"] = "usd";
queryString["LanguageCode"] = "en";
var uri = "https://dsapi-stage.directscale.com/v1/products/item/sku/{sku}?" + queryString;
var response = await client.GetAsync(uri);
}
}
}
// // 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://dsapi-stage.directscale.com/v1/products/item/sku/{sku}");
builder.setParameter("CurrencyCode", "usd");
builder.setParameter("LanguageCode", "en");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
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
"CurrencyCode": "usd",
"LanguageCode": "en",
};
$.ajax({
url: "https://dsapi-stage.directscale.com/v1/products/item/sku/{sku}?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "GET",
// 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://dsapi-stage.directscale.com/v1/products/item/sku/{sku}";
NSArray* array = @[
// Request parameters
@"entities=true",
@"CurrencyCode=usd",
@"LanguageCode=en",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
// Request headers
[_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://dsapi-stage.directscale.com/v1/products/item/sku/{sku}');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'CurrencyCode' => 'usd',
'LanguageCode' => 'en',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// 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
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
# Request parameters
'CurrencyCode': 'usd',
'LanguageCode': 'en',
})
try:
conn = httplib.HTTPSConnection('dsapi-stage.directscale.com')
conn.request("GET", "/v1/products/item/sku/{sku}?%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
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
# Request parameters
'CurrencyCode': 'usd',
'LanguageCode': 'en',
})
try:
conn = http.client.HTTPSConnection('dsapi-stage.directscale.com')
conn.request("GET", "/v1/products/item/sku/{sku}?%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://dsapi-stage.directscale.com/v1/products/item/sku/{sku}')
query = URI.encode_www_form({
# Request parameters
'CurrencyCode' => 'usd',
'LanguageCode' => 'en'
})
if uri.query && uri.query.length > 0
uri.query += '&' + query
else
uri.query = query
end
request = Net::HTTP::Get.new(uri.request_uri)
# 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