Search code examples
xmlebay-api

ebay API setNotificationPreferences


I am trying to set up notifications to an endpoint in my PHP application using the ebay Api Trading call for getNotificationPreferences. I'm finding this extremely frustrating and I am a little unnerved by the lack of examples around the web for a sample XML body to send. I have read their docs and tried to follow all eBay's own examples. Using their test tool I get errors even with their sample snippet, some of which include: "Unrecognized element <ApplicationDeliveryPreferences>" and Unrecognized element <PreferenceLevel>

Really, if I could just see an example of ONE working call that sets up a notification to a url when an item is sold I can surely take it from there. I know it is not my user token because I have used both my sandbox token and my production token. Someone help me, please!


Solution

  • I set up notifications in Developer site account settings before sending in my first GetNotificationPreferencesRequest. Go to your account, click the notifications link next to the App-ID. I think you need to indicate your web server is ready here before notifications will work, I'm not sure if you can do it all through the api. After that I was able to set my preferences with:

    <GetNotificationPreferencesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
    
    <ApplicationDeliveryPreferences>
        <AlertEnable>Enable</AlertEnable>
        <ApplicationEnable>Enable</ApplicationEnable>
        <ApplicationURL>http://YOUR-SITE.com/webhook.php</ApplicationURL>
        <DeviceType>Platform</DeviceType>
    </ApplicationDeliveryPreferences>
    
    <UserDeliveryPreferenceArray>
        <NotificationEnable>
            <EventType>ItemSold</EventType>
            <EventEnable>Enable</EventEnable>
        </NotificationEnable>
    </UserDeliveryPreferenceArray>
    
    <!-- repeat UserDeliveryPreferenceArray for each notification wanted -->
    
    </GetNotificationPreferencesRequest>