App reviews, troubleshooting, and recommendations
hi! i have this code
private function makePostRequest($url, $postData) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postData)); // Codifica a JSON aquí
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json', // Asegúrate de aceptar JSON
'Authorization: Basic ' . base64_encode("{$this->apiKey}:{$this->password}")
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$error = curl_error($curl);
curl_close($curl);
return [
'response' => json_decode($response, true),
'http_code' => $httpCode,
'error' => $error
];
}
and i trying to fulfill a order , for that i have this function
public function fulfillOrder($orderId, $location_id, $fullfilment_order_id, $trackingNumber, $trackingUrl) {
$apiUrl = "{$this->start_url}/orders/{$orderId}/fulfillments.json";
$postData = [
'fulfillment' => [
'line_items_by_fulfillment_order' => [
[
'fulfillment_order_id' => $fullfilment_order_id
]
],
'notify_customer' => true,
'tracking_info' => [
'number' => $trackingNumber,
'company' => 'Other',
'url' => $trackingUrl,
],
'location_id' => $location_id
]
];
echo $apiUrl;
$response = $this->makePostRequest($apiUrl, $postData);
echo "<pre>";
print_r($postData);
print_r($response);
echo "</pre>";
if ($response['http_code'] == 201) {
return $response['response'];
} else {
return [
'error' => $response['error'],
'http_code' => $response['http_code'],
'response' => $response['response']
];
}
}
but i got this error:
Array
(
[response] =>
[http_code] => 406
[error] =>
)
anyone can helpme pls
Hi @kahmra ,
You can try changing this line
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json', // Asegúrate de aceptar JSON
'Authorization: Basic ' . base64_encode("{$this->apiKey}:{$this->password}")
]);
to this
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-Shopify-Access-Token: ' . "{$this->password}"
]);
Let me know if it works.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025