03-17-2023 11:50 AM - edited 03-17-2023 11:51 AM
I hope that somebody can help. I know that it is communicating because when I remove something required it lets me know something is missing. With everything valid though, I get no returned response and the order doesn't show up in ShipStation. Any ideas? Maybe I overlooked something?
public function __invoke(){
$json_payload = '
{
"orderNumber": "TEST-ORDER-API-DOCS",
"orderKey": "1",
"orderDate": "2023-03-12T08:46:27.0000000",
"orderStatus": "awaiting_shipment",
"customerEmail": "headhoncho@whitehouse.gov",
"billTo": {
"name": "Tovis",
"company": "Vizcom",
"street1": "4500 Broadmoor Ave SE",
"street2": null,
"street3": null,
"city": "Grand Rapids",
"state": "MI",
"postalCode": "49512",
"country": "US",
"phone": "555-555-5555",
"residential": true
},
"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
},
"customerNotes": "Please ship as soon as possible!",
"internalNotes": "Customer called and would like to upgrade shipping",
"requestedShippingService": "Priority Mail",
"carrierCode": "fedex",
"serviceCode": "fedex_2day",
"packageCode": "package",
"confirmation": "delivery",
"shipDate": "2023-03-20",
"weight": {
"value": 25,
"units": "ounces"
},
"dimensions": {
"units": "inches",
"length": 7,
"width": 5,
"height": 6
}
}
';
$key = config('shipstation.key');
$secret = config('shipstation.secret');
$url = 'https://ssapi.shipstation.com/orders/createorder';
$credentials = base64_encode("$key:$secret");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/json',
'Host: ssapi.shipstation.com',
"Authorization: Basic $credentials",
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_payload);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
03-21-2023 10:45 AM
Hey there @tovis,
Thanks for joining us here in the community!
I'm hopeful that another member that is an API expert will help us out here!
If you'd like, you can also reach out directly to our API support team at apisupport@shipstation.com and they will be happy to assist 🙂
06-30-2023 07:59 AM
Hey,
If you are trying to create an new order omit the "orderKey" key-value pair. This is only needed if you are updating an order.
There may be other issues; I normally use python when using the API not curl.
I recommend testing the endpoint by omitting as much data first to find which fields are giving you the error.
Including the HTTP code in your question could also help solve your issues.
07-25-2023 12:33 AM
Hi,
Even I'm facing a similar issue. When making a request to createorder API endpoint, getting a 401 response with a null body. No error message was displayed whatsoever. When a similar request was placed 3 min later, the order was successful. When I say similar, I mean everything same btw the two requests except for the date& time and order no.
Could you pls lmk what went wrong?
Because a lot of our clients are facing issues with the Shipstation orders and we're unable to debug them.
Kindly advise.
Thanks!