09-01-2023 05:13 AM
Hi All,
I have created developer account with all information. But whenever i am trying to use inventory update it gives me error for "Insufficient permissions to fulfill the request".
Also cannot found any permission related settings for this.
I am trying to update the inventory quantity by API.
Here is my code.
// eBay API endpoint
$endpoint = "https://api.ebay.com/sell/inventory/v1/inventory_item/36403757XXXX";
// API request data for updating stock
$data = array(
"availability" => array(
"shipToLocationAvailability" => array(
"quantity" => 50, // New stock quantity
),
),
);
// Convert the data to JSON
$data_json = json_encode($data);
// eBay API headers
$headers = array(
"Authorization: Bearer MY_TOKEN",
"Content-Type: application/json",
);
// Initialize cURL session
$ch = curl_init($endpoint);
// Set cURL options
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
}
// Close the cURL session
curl_close($ch);
// Check the API response
if ($response) {
$response_data = json_decode($response, true);
if (isset($response_data['HTTPStatusCode']) && $response_data['HTTPStatusCode'] == 200) {
echo "Stock updated successfully.";
} else {
echo "Error updating stock: " . print_r($response_data, true);
}
} else {
echo "No response received.";
}
Also I have tried this on API Explorer and it works fine for search and single item details. But same error for inventory related services.
Any Help will be appreciated.
thanks
09-12-2023 05:48 AM
May be you hav'nt set the OAuth scope: https://api.ebay.com/oauth/api_scope/sell.inventory for your user token.
09-12-2023 06:01 AM
@ardonis-2000
have you any idea how to set OAuth scope,
Because at the time of OAuth token no selection for scope.