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.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024