This call does not currently support partial updates. The entire resource must be provided in the body of the request.
POST /orders/createorder HTTP/1.1
Host: ssapi.shipstation.com
Authorization: __YOUR_AUTH_HERE__
Content-Type: application/json
{
"orderNumber": "TEST-ORDER-API-DOCS",
"orderKey": "0f6bec18-3e89-4881-83aa-f392d84f4c74",
"orderDate": "2015-06-29T08:46:27.0000000",
"paymentDate": "2015-06-29T08:46:27.0000000",
"shipByDate": "2015-07-05T00:00:00.0000000",
"orderStatus": "awaiting_shipment",
"customerId": 37701499,
"customerUsername": "[email protected]",
"customerEmail": "[email protected]",
"billTo": {
"name": "The President",
"company": null,
"street1": null,
"street2": null,
"street3": null,
"city": null,
"state": null,
"postalCode": null,
"country": null,
"phone": null,
"residential": null
},
"shipTo": {
"name": "The President",
"company": "US Govt",
"street1": "1600 Pennsylvania Ave",
"street2": "Oval Office",
"street3": null,
"city": "Washington",
"state": "DC",
"postalCode": "20500",
"country": "US",
"phone": "555-555-5555",
"residential": true
},
"items": [
{
"lineItemKey": "vd08-MSLbtx",
"sku": "ABC123",
"name": "Test item #1",
"imageUrl": null,
"weight": {
"value": 24,
"units": "ounces"
},
"quantity": 2,
"unitPrice": 99.99,
"taxAmount": 2.5,
"shippingAmount": 5,
"warehouseLocation": "Aisle 1, Bin 7",
"options": [
{
"name": "Size",
"value": "Large"
}
],
"productId": 123456,
"fulfillmentSku": null,
"adjustment": false,
"upc": "32-65-98"
},
{
"lineItemKey": null,
"sku": "DISCOUNT CODE",
"name": "10% OFF",
"imageUrl": null,
"weight": {
"value": 0,
"units": "ounces"
},
"quantity": 1,
"unitPrice": -20.55,
"taxAmount": null,
"shippingAmount": null,
"warehouseLocation": null,
"options": [],
"productId": 123456,
"fulfillmentSku": "SKU-Discount",
"adjustment": true,
"upc": null
}
],
"amountPaid": 218.73,
"taxAmount": 5,
"shippingAmount": 10,
"customerNotes": "Please ship as soon as possible!",
"internalNotes": "Customer called and would like to upgrade shipping",
"gift": true,
"giftMessage": "Thank you!",
"paymentMethod": "Credit Card",
"requestedShippingService": "Priority Mail",
"carrierCode": "fedex",
"serviceCode": "fedex_2day",
"packageCode": "package",
"confirmation": "delivery",
"shipDate": "2015-07-02",
"weight": {
"value": 25,
"units": "ounces"
},
"dimensions": {
"units": "inches",
"length": 7,
"width": 5,
"height": 6
},
"insuranceOptions": {
"provider": "carrier",
"insureShipment": true,
"insuredValue": 200
},
"internationalOptions": {
"contents": null,
"customsItems": null
},
"advancedOptions": {
"warehouseId": null,
"nonMachinable": false,
"saturdayDelivery": false,
"containsAlcohol": false,
"mergedOrSplit": false,
"mergedIds": [],
"parentId": null,
"storeId": null,
"customField1": "Custom data that you can add to an order. See Custom Field #2 & #3 for more info!",
"customField2": "Per UI settings, this information can appear on some carrier's shipping labels. See link below",
"customField3": "https://help.shipstation.com/hc/en-us/articles/206639957",
"source": "Webstore",
"billToParty": null,
"billToAccount": null,
"billToPostalCode": null,
"billToCountryCode": null
},
"tagIds": [
53974
]
}
curl -iX POST https://ssapi.shipstation.com/orders/createorder \
-H 'Authorization: __YOUR_AUTH_HERE__' \
-H 'Content-Type: application/json' \
-d '{
"orderNumber": "TEST-ORDER-API-DOCS",
"orderKey": "0f6bec18-3e89-4881-83aa-f392d84f4c74",
"orderDate": "2015-06-29T08:46:27.0000000",
"paymentDate": "2015-06-29T08:46:27.0000000",
"shipByDate": "2015-07-05T00:00:00.0000000",
"orderStatus": "awaiting_shipment",
"customerId": 37701499,
"customerUsername": "[email protected]",
"customerEmail": "[email protected]",
"billTo": {
"name": "The President",
"company": null,
"street1": null,
"street2": null,
"street3": null,
"city": null,
"state": null,
"postalCode": null,
"country": null,
"phone": null,
"residential": null
},
"shipTo": {
"name": "The President",
"company": "US Govt",
"street1": "1600 Pennsylvania Ave",
"street2": "Oval Office",
"street3": null,
"city": "Washington",
"state": "DC",
"postalCode": "20500",
"country": "US",
"phone": "555-555-5555",
"residential": true
},
"items": [
{
"lineItemKey": "vd08-MSLbtx",
"sku": "ABC123",
"name": "Test item #1",
"imageUrl": null,
"weight": {
"value": 24,
"units": "ounces"
},
"quantity": 2,
"unitPrice": 99.99,
"taxAmount": 2.5,
"shippingAmount": 5,
"warehouseLocation": "Aisle 1, Bin 7",
"options": [
{
"name": "Size",
"value": "Large"
}
],
"productId": 123456,
"fulfillmentSku": null,
"adjustment": false,
"upc": "32-65-98"
},
{
"lineItemKey": null,
"sku": "DISCOUNT CODE",
"name": "10% OFF",
"imageUrl": null,
"weight": {
"value": 0,
"units": "ounces"
},
"quantity": 1,
"unitPrice": -20.55,
"taxAmount": null,
"shippingAmount": null,
"warehouseLocation": null,
"options": [],
"productId": 123456,
"fulfillmentSku": "SKU-Discount",
"adjustment": true,
"upc": null
}
],
"amountPaid": 218.73,
"taxAmount": 5,
"shippingAmount": 10,
"customerNotes": "Please ship as soon as possible!",
"internalNotes": "Customer called and would like to upgrade shipping",
"gift": true,
"giftMessage": "Thank you!",
"paymentMethod": "Credit Card",
"requestedShippingService": "Priority Mail",
"carrierCode": "fedex",
"serviceCode": "fedex_2day",
"packageCode": "package",
"confirmation": "delivery",
"shipDate": "2015-07-02",
"weight": {
"value": 25,
"units": "ounces"
},
"dimensions": {
"units": "inches",
"length": 7,
"width": 5,
"height": 6
},
"insuranceOptions": {
"provider": "carrier",
"insureShipment": true,
"insuredValue": 200
},
"internationalOptions": {
"contents": null,
"customsItems": null
},
"advancedOptions": {
"warehouseId": null,
"nonMachinable": false,
"saturdayDelivery": false,
"containsAlcohol": false,
"mergedOrSplit": false,
"mergedIds": [],
"parentId": null,
"storeId": null,
"customField1": "Custom data that you can add to an order. See Custom Field #2 & #3 for more info!",
"customField2": "Per UI settings, this information can appear on some carrier's shipping labels. See link below",
"customField3": "https://help.shipstation.com/hc/en-us/articles/206639957",
"source": "Webstore",
"billToParty": null,
"billToAccount": null,
"billToPostalCode": null,
"billToCountryCode": null
},
"tagIds": [
53974
]
}'
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "ssapi.shipstation.com")
$headers.Add("Authorization", "__YOUR_AUTH_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "{`n `"orderNumber`": `"TEST-ORDER-API-DOCS`",`n `"orderKey`": `"0f6bec18-3e89-4881-83aa-f392d84f4c74`",`n `"orderDate`": `"2015-06-29T08:46:27.0000000`",`n `"paymentDate`": `"2015-06-29T08:46:27.0000000`",`n `"shipByDate`": `"2015-07-05T00:00:00.0000000`",`n `"orderStatus`": `"awaiting_shipment`",`n `"customerId`": 37701499,`n `"customerUsername`": `"[email protected]`",`n `"customerEmail`": `"[email protected]`",`n `"billTo`": {`n `"name`": `"The President`",`n `"company`": null,`n `"street1`": null,`n `"street2`": null,`n `"street3`": null,`n `"city`": null,`n `"state`": null,`n `"postalCode`": null,`n `"country`": null,`n `"phone`": null,`n `"residential`": null`n },`n `"shipTo`": {`n `"name`": `"The President`",`n `"company`": `"US Govt`",`n `"street1`": `"1600 Pennsylvania Ave`",`n `"street2`": `"Oval Office`",`n `"street3`": null,`n `"city`": `"Washington`",`n `"state`": `"DC`",`n `"postalCode`": `"20500`",`n `"country`": `"US`",`n `"phone`": `"555-555-5555`",`n `"residential`": true`n },`n `"items`": [`n {`n `"lineItemKey`": `"vd08-MSLbtx`",`n `"sku`": `"ABC123`",`n `"name`": `"Test item #1`",`n `"imageUrl`": null,`n `"weight`": {`n `"value`": 24,`n `"units`": `"ounces`"`n },`n `"quantity`": 2,`n `"unitPrice`": 99.99,`n `"taxAmount`": 2.5,`n `"shippingAmount`": 5,`n `"warehouseLocation`": `"Aisle 1, Bin 7`",`n `"options`": [`n {`n `"name`": `"Size`",`n `"value`": `"Large`"`n }`n ],`n `"productId`": 123456,`n `"fulfillmentSku`": null,`n `"adjustment`": false,`n `"upc`": `"32-65-98`"`n },`n {`n `"lineItemKey`": null,`n `"sku`": `"DISCOUNT CODE`",`n `"name`": `"10% OFF`",`n `"imageUrl`": null,`n `"weight`": {`n `"value`": 0,`n `"units`": `"ounces`"`n },`n `"quantity`": 1,`n `"unitPrice`": -20.55,`n `"taxAmount`": null,`n `"shippingAmount`": null,`n `"warehouseLocation`": null,`n `"options`": [],`n `"productId`": 123456,`n `"fulfillmentSku`": `"SKU-Discount`",`n `"adjustment`": true,`n `"upc`": null`n }`n ],`n `"amountPaid`": 218.73,`n `"taxAmount`": 5,`n `"shippingAmount`": 10,`n `"customerNotes`": `"Please ship as soon as possible!`",`n `"internalNotes`": `"Customer called and would like to upgrade shipping`",`n `"gift`": true,`n `"giftMessage`": `"Thank you!`",`n `"paymentMethod`": `"Credit Card`",`n `"requestedShippingService`": `"Priority Mail`",`n `"carrierCode`": `"fedex`",`n `"serviceCode`": `"fedex_2day`",`n `"packageCode`": `"package`",`n `"confirmation`": `"delivery`",`n `"shipDate`": `"2015-07-02`",`n `"weight`": {`n `"value`": 25,`n `"units`": `"ounces`"`n },`n `"dimensions`": {`n `"units`": `"inches`",`n `"length`": 7,`n `"width`": 5,`n `"height`": 6`n },`n `"insuranceOptions`": {`n `"provider`": `"carrier`",`n `"insureShipment`": true,`n `"insuredValue`": 200`n },`n `"internationalOptions`": {`n `"contents`": null,`n `"customsItems`": null`n },`n `"advancedOptions`": {`n `"warehouseId`": null,`n `"nonMachinable`": false,`n `"saturdayDelivery`": false,`n `"containsAlcohol`": false,`n `"mergedOrSplit`": false,`n `"mergedIds`": [],`n `"parentId`": null,`n `"storeId`": null,`n `"customField1`": `"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!`",`n `"customField2`": `"Per UI settings, this information can appear on some carrier's shipping labels. See link below`",`n `"customField3`": `"https://help.shipstation.com/hc/en-us/articles/206639957`",`n `"source`": `"Webstore`",`n `"billToParty`": null,`n `"billToAccount`": null,`n `"billToPostalCode`": null,`n `"billToCountryCode`": null`n },`n `"tagIds`": [`n 53974`n ]`n}"
$response = Invoke-RestMethod 'https://ssapi.shipstation.com/orders/createorder' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
var myHeaders = new Headers();
myHeaders.append("Host", "ssapi.shipstation.com");
myHeaders.append("Authorization", "__YOUR_AUTH_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({"orderNumber":"TEST-ORDER-API-DOCS","orderKey":"0f6bec18-3e89-4881-83aa-f392d84f4c74","orderDate":"2015-06-29T08:46:27.0000000","paymentDate":"2015-06-29T08:46:27.0000000","shipByDate":"2015-07-05T00:00:00.0000000","orderStatus":"awaiting_shipment","customerId":37701499,"customerUsername":"[email protected]","customerEmail":"[email protected]","billTo":{"name":"The President","company":null,"street1":null,"street2":null,"street3":null,"city":null,"state":null,"postalCode":null,"country":null,"phone":null,"residential":null},"shipTo":{"name":"The President","company":"US Govt","street1":"1600 Pennsylvania Ave","street2":"Oval Office","street3":null,"city":"Washington","state":"DC","postalCode":"20500","country":"US","phone":"555-555-5555","residential":true},"items":[{"lineItemKey":"vd08-MSLbtx","sku":"ABC123","name":"Test item #1","imageUrl":null,"weight":{"value":24,"units":"ounces"},"quantity":2,"unitPrice":99.99,"taxAmount":2.5,"shippingAmount":5,"warehouseLocation":"Aisle 1, Bin 7","options":[{"name":"Size","value":"Large"}],"productId":123456,"fulfillmentSku":null,"adjustment":false,"upc":"32-65-98"},{"lineItemKey":null,"sku":"DISCOUNT CODE","name":"10% OFF","imageUrl":null,"weight":{"value":0,"units":"ounces"},"quantity":1,"unitPrice":-20.55,"taxAmount":null,"shippingAmount":null,"warehouseLocation":null,"options":[],"productId":123456,"fulfillmentSku":"SKU-Discount","adjustment":true,"upc":null}],"amountPaid":218.73,"taxAmount":5,"shippingAmount":10,"customerNotes":"Please ship as soon as possible!","internalNotes":"Customer called and would like to upgrade shipping","gift":true,"giftMessage":"Thank you!","paymentMethod":"Credit Card","requestedShippingService":"Priority Mail","carrierCode":"fedex","serviceCode":"fedex_2day","packageCode":"package","confirmation":"delivery","shipDate":"2015-07-02","weight":{"value":25,"units":"ounces"},"dimensions":{"units":"inches","length":7,"width":5,"height":6},"insuranceOptions":{"provider":"carrier","insureShipment":true,"insuredValue":200},"internationalOptions":{"contents":null,"customsItems":null},"advancedOptions":{"warehouseId":null,"nonMachinable":false,"saturdayDelivery":false,"containsAlcohol":false,"mergedOrSplit":false,"mergedIds":[],"parentId":null,"storeId":null,"customField1":"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!","customField2":"Per UI settings, this information can appear on some carrier's shipping labels. See link below","customField3":"https://help.shipstation.com/hc/en-us/articles/206639957","source":"Webstore","billToParty":null,"billToAccount":null,"billToPostalCode":null,"billToCountryCode":null},"tagIds":[53974]});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://ssapi.shipstation.com/orders/createorder", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://ssapi.shipstation.com/orders/createorder',
'headers': {
'Host': 'ssapi.shipstation.com',
'Authorization': '__YOUR_AUTH_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify({"orderNumber":"TEST-ORDER-API-DOCS","orderKey":"0f6bec18-3e89-4881-83aa-f392d84f4c74","orderDate":"2015-06-29T08:46:27.0000000","paymentDate":"2015-06-29T08:46:27.0000000","shipByDate":"2015-07-05T00:00:00.0000000","orderStatus":"awaiting_shipment","customerId":37701499,"customerUsername":"[email protected]","customerEmail":"[email protected]","billTo":{"name":"The President","company":null,"street1":null,"street2":null,"street3":null,"city":null,"state":null,"postalCode":null,"country":null,"phone":null,"residential":null},"shipTo":{"name":"The President","company":"US Govt","street1":"1600 Pennsylvania Ave","street2":"Oval Office","street3":null,"city":"Washington","state":"DC","postalCode":"20500","country":"US","phone":"555-555-5555","residential":true},"items":[{"lineItemKey":"vd08-MSLbtx","sku":"ABC123","name":"Test item #1","imageUrl":null,"weight":{"value":24,"units":"ounces"},"quantity":2,"unitPrice":99.99,"taxAmount":2.5,"shippingAmount":5,"warehouseLocation":"Aisle 1, Bin 7","options":[{"name":"Size","value":"Large"}],"productId":123456,"fulfillmentSku":null,"adjustment":false,"upc":"32-65-98"},{"lineItemKey":null,"sku":"DISCOUNT CODE","name":"10% OFF","imageUrl":null,"weight":{"value":0,"units":"ounces"},"quantity":1,"unitPrice":-20.55,"taxAmount":null,"shippingAmount":null,"warehouseLocation":null,"options":[],"productId":123456,"fulfillmentSku":"SKU-Discount","adjustment":true,"upc":null}],"amountPaid":218.73,"taxAmount":5,"shippingAmount":10,"customerNotes":"Please ship as soon as possible!","internalNotes":"Customer called and would like to upgrade shipping","gift":true,"giftMessage":"Thank you!","paymentMethod":"Credit Card","requestedShippingService":"Priority Mail","carrierCode":"fedex","serviceCode":"fedex_2day","packageCode":"package","confirmation":"delivery","shipDate":"2015-07-02","weight":{"value":25,"units":"ounces"},"dimensions":{"units":"inches","length":7,"width":5,"height":6},"insuranceOptions":{"provider":"carrier","insureShipment":true,"insuredValue":200},"internationalOptions":{"contents":null,"customsItems":null},"advancedOptions":{"warehouseId":null,"nonMachinable":false,"saturdayDelivery":false,"containsAlcohol":false,"mergedOrSplit":false,"mergedIds":[],"parentId":null,"storeId":null,"customField1":"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!","customField2":"Per UI settings, this information can appear on some carrier's shipping labels. See link below","customField3":"https://help.shipstation.com/hc/en-us/articles/206639957","source":"Webstore","billToParty":null,"billToAccount":null,"billToPostalCode":null,"billToCountryCode":null},"tagIds":[53974]})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://ssapi.shipstation.com/orders/createorder",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}",
CURLOPT_HTTPHEADER => array(
"Host: ssapi.shipstation.com",
"Authorization: __YOUR_AUTH_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://ssapi.shipstation.com/orders/createorder"
payload = "{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}"
headers = {
'Host': 'ssapi.shipstation.com',
'Authorization': '__YOUR_AUTH_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://ssapi.shipstation.com/orders/createorder")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "ssapi.shipstation.com"
request["Authorization"] = "__YOUR_AUTH_HERE__"
request["Content-Type"] = "application/json"
request.body = "{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://ssapi.shipstation.com/orders/createorder");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "ssapi.shipstation.com");
request.AddHeader("Authorization", "__YOUR_AUTH_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}");
Request request = new Request.Builder()
.url("https://ssapi.shipstation.com/orders/createorder")
.method("POST", body)
.addHeader("Host", "ssapi.shipstation.com")
.addHeader("Authorization", "__YOUR_AUTH_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://ssapi.shipstation.com/orders/createorder"
method := "POST"
payload := strings.NewReader("{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "ssapi.shipstation.com")
req.Header.Add("Authorization", "__YOUR_AUTH_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ssapi.shipstation.com/orders/createorder"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"ssapi.shipstation.com",
@"Authorization": @"__YOUR_AUTH_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\n \"orderNumber\": \"TEST-ORDER-API-DOCS\",\n \"orderKey\": \"0f6bec18-3e89-4881-83aa-f392d84f4c74\",\n \"orderDate\": \"2015-06-29T08:46:27.0000000\",\n \"paymentDate\": \"2015-06-29T08:46:27.0000000\",\n \"shipByDate\": \"2015-07-05T00:00:00.0000000\",\n \"orderStatus\": \"awaiting_shipment\",\n \"customerId\": 37701499,\n \"customerUsername\": \"[email protected]\",\n \"customerEmail\": \"[email protected]\",\n \"billTo\": {\n \"name\": \"The President\",\n \"company\": null,\n \"street1\": null,\n \"street2\": null,\n \"street3\": null,\n \"city\": null,\n \"state\": null,\n \"postalCode\": null,\n \"country\": null,\n \"phone\": null,\n \"residential\": null\n },\n \"shipTo\": {\n \"name\": \"The President\",\n \"company\": \"US Govt\",\n \"street1\": \"1600 Pennsylvania Ave\",\n \"street2\": \"Oval Office\",\n \"street3\": null,\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"postalCode\": \"20500\",\n \"country\": \"US\",\n \"phone\": \"555-555-5555\",\n \"residential\": true\n },\n \"items\": [\n {\n \"lineItemKey\": \"vd08-MSLbtx\",\n \"sku\": \"ABC123\",\n \"name\": \"Test item #1\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 24,\n \"units\": \"ounces\"\n },\n \"quantity\": 2,\n \"unitPrice\": 99.99,\n \"taxAmount\": 2.5,\n \"shippingAmount\": 5,\n \"warehouseLocation\": \"Aisle 1, Bin 7\",\n \"options\": [\n {\n \"name\": \"Size\",\n \"value\": \"Large\"\n }\n ],\n \"productId\": 123456,\n \"fulfillmentSku\": null,\n \"adjustment\": false,\n \"upc\": \"32-65-98\"\n },\n {\n \"lineItemKey\": null,\n \"sku\": \"DISCOUNT CODE\",\n \"name\": \"10% OFF\",\n \"imageUrl\": null,\n \"weight\": {\n \"value\": 0,\n \"units\": \"ounces\"\n },\n \"quantity\": 1,\n \"unitPrice\": -20.55,\n \"taxAmount\": null,\n \"shippingAmount\": null,\n \"warehouseLocation\": null,\n \"options\": [],\n \"productId\": 123456,\n \"fulfillmentSku\": \"SKU-Discount\",\n \"adjustment\": true,\n \"upc\": null\n }\n ],\n \"amountPaid\": 218.73,\n \"taxAmount\": 5,\n \"shippingAmount\": 10,\n \"customerNotes\": \"Please ship as soon as possible!\",\n \"internalNotes\": \"Customer called and would like to upgrade shipping\",\n \"gift\": true,\n \"giftMessage\": \"Thank you!\",\n \"paymentMethod\": \"Credit Card\",\n \"requestedShippingService\": \"Priority Mail\",\n \"carrierCode\": \"fedex\",\n \"serviceCode\": \"fedex_2day\",\n \"packageCode\": \"package\",\n \"confirmation\": \"delivery\",\n \"shipDate\": \"2015-07-02\",\n \"weight\": {\n \"value\": 25,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"insuranceOptions\": {\n \"provider\": \"carrier\",\n \"insureShipment\": true,\n \"insuredValue\": 200\n },\n \"internationalOptions\": {\n \"contents\": null,\n \"customsItems\": null\n },\n \"advancedOptions\": {\n \"warehouseId\": null,\n \"nonMachinable\": false,\n \"saturdayDelivery\": false,\n \"containsAlcohol\": false,\n \"mergedOrSplit\": false,\n \"mergedIds\": [],\n \"parentId\": null,\n \"storeId\": null,\n \"customField1\": \"Custom data that you can add to an order. See Custom Field #2 & #3 for more info!\",\n \"customField2\": \"Per UI settings, this information can appear on some carrier's shipping labels. See link below\",\n \"customField3\": \"https://help.shipstation.com/hc/en-us/articles/206639957\",\n \"source\": \"Webstore\",\n \"billToParty\": null,\n \"billToAccount\": null,\n \"billToPostalCode\": null,\n \"billToCountryCode\": null\n },\n \"tagIds\": [\n 53974\n ]\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://ssapi.shipstation.com/orders/createorder")!,timeoutInterval: Double.infinity)
request.addValue("ssapi.shipstation.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_AUTH_HERE__", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()