curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
headerList = curl_slist_append(headerList, "Authorization: Basic TOKENHERE=");
sprintf_s(targUrl, "https://myurl/createorder");
curl_easy_setopt(curl, CURLOPT_URL, targUrl);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataToPost);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, datalen);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerList);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeCallback);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_CAINFO, "C:\\path\\cacert.pem");
curl_easy_perform(curl);
{ \"orderId\": \"12345\", \"orderDate\": \"2015-04-08T15:30:29\", \"paymentDate\": \"2015-04-08T15:30:29\", \"orderStatus\": \"waiting\", \"customerUsername\": \"usrnm\", \"customerEmail\": null, \"billTo\": { \"name\": \"test\", \"company\": null, \"street1\": null, \"street2\": null, \"street3\": null, \"city\": null, \"state\": null, \"postalCode\": null, \"country\": \"US\", \"phone\": null, \"residential\": null }, \"shipTo\": { \"name\": \"John Doe\", \"company\": null, \"street1\": \"123 Test\", \"street2\": \"test\", \"street3\": null, \"city\": \"test\", \"state\": \"CA\", \"postalCode\": \"11111\", \"country\": \"US\", \"phone\": \"555-1212\", \"residential\": true }, \"items\": [ { \"lineItemKey\": null, \"sku\": \"11111\", \"name\": \"test\", \"imageUrl\": null, \"weight\": { \"value\": 24, \"units\": \"ounces\" }, \"quantity\": 2, \"unitPrice\": 6.86, \"warehouseLocation\": null, \"options\": [] } ], \"amountPaid\": 10.72, \"taxAmount\": 0, \"shippingAmount\": 0, \"customerNotes\": null, \"internalNotes\": \" \", \"gift\": false, \"giftMessage\": null, \"requestedShippingService\": \"UPS\", \"paymentMethod\": null, \"carrierCode\": \"ups\", \"serviceCode\": \"ups_ground\", \"packageCode\": null, \"confirmation\": null, \"shipDate\": \"2015-04-08\", \"weight\": { \"value\": 0, \"units\": \"ounces\" }, \"dimensions\": { \"units\": \"inches\", \"length\": 7, \"width\": 5, \"height\": 6 }, \"insuranceOptions\": { \"provider\": null, \"insureShipment\": false, \"insuredValue\": 0 }, \"internationalOptions\": { \"contents\": null, \"customsItems\": null }, \"advancedOptions\": { \"warehouseId\": 14933, \"nonMachinable\": false, \"saturdayDelivery\": false, \"containsAlcohol\": false, \"storeId\": 9, \"customField1\": \"Some custom data\", \"customField2\": null, \"customField3\": null, \"source\": null }}
BTW, here's a simple escaping helper for JSON data taken from production code:
Open in new window