Why am I getting an error with my custom API in PHP?

Hi,

I have developed PHP api code for getting an orders list but getting error {“errors”:“Not Found”}

Code

$API_KEY = '******************************';
$PASSWORD = '******************************';
$STORE_URL = '*********.myshopify.com';

$url = 'https://' . $API_KEY . ':' . $PASSWORD . '@' . $STORE_URL . '/admin/api/2022-09/orders.json?status=any';
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //can check status code, requst successfully processed if return 200
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $result;

Please help me.

Hi @chandrakantb36

change it to ‘2022-07’ https://shopify.dev/api/admin-rest

1 Like