I can read products and delete products but I cannot create or update.
I’m using the phpclassic/shopifysdk
I’ve checked the json and it’s valid, I’m totally stuck
public function __construct()
{
$config = array(
"ShopUrl" => $_ENV["SHOPIFY_SHOP_URL"],
"AccessToken" => $_ENV["SHOPIFY_ACCESS_TOKEN"],
"Curl" => array(
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true
)
);
$this->shopify = new ShopifySDK($config);
}
public function apiAddProduct($data) : void
{
$jsonData = json_encode($data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
try {
$response = $this->shopify->Product->post($jsonData);
error_log("Response: " . print_r($response, true));
} catch (CurlException $e) {
$this->addError("product", $e->getMessage());
error_log("CurlException: " . $e->getMessage());
} catch (\Exception $e) {
$this->addError("product", $e->getMessage());
error_log("Exception: " . $e->getMessage());
}
}
Every time i try to submit the data I get a 400 response, with no other details or errors.