07-31-2023 02:16 PM
Hello,
I am trying to get the set of IDs that are eligible for a seller-initiated discount offer to a buyer by calling GET https://api.ebay.com/sell/negotiation/v1/find_eligible_items as per https://developer.ebay.com/api-docs/sell/negotiation/resources/offer/methods/findEligibleItems.
Here is my code:
08-12-2023 12:13 PM
Are you sure you're generating a User Access Token and not an Application Access token? The Marketplace API expects a GET which is generally associated with 'Application access' credentials.
"Application tokens are general-use tokens that give access to interfaces that return application data. For example, many GET requests require only an Application token for authorization."
https://developer.ebay.com/api-docs/static/oauth-token-types.html#:~:text=For%20example%2C%20many%20....
Here's my working example (tested with a User Access Token):
<?php
function findEligibleItems($UserAccessToken) {
$headers = array(
'Authorization: Bearer ' . $UserAccessToken,
'X-EBAY-C-MARKETPLACE-ID: EBAY_US',
'Content-Type: application/json'
);
$params = array(
'limit' => '100'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.ebay.com/sell/negotiation/v1/find_eligible_items?' . http_build_query($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$UserAccessToken = file_get_contents('token.txt'); // put user access token in text file
$find = findEligibleItems($UserAccessToken);
var_dump($find);
08-12-2023 12:15 PM
Python version, also tested and working:
def findEligibleItems():
headers = {
'Authorization': 'Bearer ' + UserAccessToken,
'X-EBAY-C-MARKETPLACE-ID': 'EBAY_US',
'Content-Type': 'application/json',
}
params = {
'limit': '100',
}
response = requests.get('https://api.ebay.com/sell/negotiation/v1/find_eligible_items',
params=params, headers=headers)