2

I'm trying to list an item on eBay with the eBay Trading API using PHP and CURL

Everything (XML and my script) looks OK or I just don't see what I'm doing wrong.

This is my request:

<?xml version="1.0" encoding="utf-8"?>
<AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>en_US</ErrorLanguage>  
<AddItemRequestContainer>  
<MessageID>100</MessageID>  
<Item>  
<BuyItNowPrice>238.00</BuyItNowPrice>  
<CategoryMappingAllowed>true</CategoryMappingAllowed>  
<ConditionID>1000</ConditionID>  
<Country>CA</Country>  
<Currency>CAD</Currency>  
<Title>TEST</Title>  
<Description>DEscription</Description>  
<DispatchTimeMax>3</DispatchTimeMax>  
<ListingDuration>Days_7</ListingDuration>  
<ListingType>FixedPriceItem</ListingType>  
<PaymentMethods>PayPal</PaymentMethods>  
<PayPalEmailAddress>paypal@jccayer.com</PayPalEmailAddress>  
<PictureDetails>  
<Item.PictureDetails.PictureURL>  
http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg  
</Item.PictureDetails.PictureURL>  
<PictureURL>http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg</PictureURL>  
</PictureDetails>  
<PostalCode>K0A1M0</PostalCode>  
<PrimaryCategory>  
<CategoryID>279</CategoryID>  
</PrimaryCategory>  
<Quantity>1</Quantity>  
<ReturnPolicy>  
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>  
<RefundOption>MoneyBack</RefundOption>  
<ReturnsWithinOption>Days_30</ReturnsWithinOption>  
<Description>Text description of return policy details</Description>  
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>  
</ReturnPolicy>  
<ShippingDetails>  
<ShippingType>Flat</ShippingType>  
<ShippingServiceOptions>  
<ShippingServicePriority>1</ShippingServicePriority>  
<ShippingService>CA_UPSStandardCanada</ShippingService>  
<ShippingServiceCost>21.50</ShippingServiceCost>  
</ShippingServiceOptions>  
</ShippingDetails>  
<Site>Canada</Site>  
<UUID>4d8b04a3ae054a978a66848fafd524c9</UUID>  
</Item>  
</AddItemRequestContainer>  
<RequesterCredentials>  
<eBayAuthToken>[INSERT YOUR OWN AUTH TOKEN]</eBayAuthToken>  
</RequesterCredentials>  
</AddItemsRequest>

Response:

Array
(
[Timestamp] => 2013-08-22T13:16:02.397Z
[Ack] => Failure
[Errors] => Array
    (
        [ShortMessage] => Invalid job context type
        [LongMessage] => The job context object is not supported by Action Service Framework.
        [ErrorCode] => 21843
        [SeverityCode] => Error
        [ErrorParameters] => Array
            (
                [0] => Array
                    (
                        [@attributes] => Array
                            (
                                [ParamID] => 0
                            )

                        [Value] => AddItem
                    )

                [1] => Array
                    (
                        [@attributes] => Array
                            (
                                [ParamID] => 1
                            )

                        [Value] => AddItemsRequestType
                    )

            )

        [ErrorClassification] => RequestError
    )

[Version] => 833
[Build] => E833_UNI_API5_16246498_R1
)

Anyone have an idea what could be wrong?


Edit

As i got the answer from David T. Sadler he advised me to try to use StartingPrice instead of BuyItNowPrice

So that is what I did. Also David said he was able to run my XML through the API testing tool. When I tried it, it did not work over there either.

Here is my new request

Headers

X-EBAY-API-COMPATIBILITY-LEVEL:833
X-EBAY-API-DEV-NAME:76803363-a07b-4c24-b5c7-f38ce3dd1ba7
X-EBAY-API-APP-NAME:JeanClau-bd2d-4e64-9466-41fbecfb8bb6
X-EBAY-API-CERT-NAME:4624a573-0320-4604-ac18-f7fc07d0ea8b
X-EBAY-API-SITEID:2
X-EBAY-API-CALL-NAME:AddItem

XML Request

<?xml version="1.0" encoding="utf-8"?> 
<AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents">  
<ErrorLanguage>en_US</ErrorLanguage>    
<AddItemRequestContainer>    
<MessageID>100</MessageID>    
<Item>    
<StartingPrice>238.00</StartingPrice>    
<CategoryMappingAllowed>true</CategoryMappingAllowed>    
<ConditionID>1000</ConditionID>    
<Country>CA</Country>    
<Currency>CAD</Currency>    
<Title>TEST</Title>    
<Description>DEscription</Description>    
<DispatchTimeMax>3</DispatchTimeMax>    
<ListingDuration>Days_7</ListingDuration>    
<ListingType>FixedPriceItem</ListingType>    
<PaymentMethods>PayPal</PaymentMethods>    
<PayPalEmailAddress>paypal@jccayer.com</PayPalEmailAddress>    
<PictureDetails>    
<Item.PictureDetails.PictureURL>    
http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg    
</Item.PictureDetails.PictureURL>    
<PictureURL>http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg</PictureURL>    
</PictureDetails>    
<PostalCode>K0A1M0</PostalCode>    
<PrimaryCategory>    
<CategoryID>279</CategoryID>    
</PrimaryCategory>    
<Quantity>1</Quantity>    
<ReturnPolicy>    
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>    
<RefundOption>MoneyBack</RefundOption>    
<ReturnsWithinOption>Days_30</ReturnsWithinOption>    
<Description>Text description of return policy details</Description>    
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>    
</ReturnPolicy>    
<ShippingDetails>    
<ShippingType>Flat</ShippingType>    
<ShippingServiceOptions>    
<ShippingServicePriority>1</ShippingServicePriority>    
<ShippingService>CA_UPSStandardCanada</ShippingService>    
<ShippingServiceCost>21.50</ShippingServiceCost>    
</ShippingServiceOptions>    
</ShippingDetails>    
<Site>Canada</Site>    
<UUID>4d8b04a3ae054a978a66848fafd524c9</UUID>    
</Item>    
</AddItemRequestContainer>    
<RequesterCredentials>    
<eBayAuthToken>[INSERT YOUR OWN AUTH TOKEN]</eBayAuthToken>    
</RequesterCredentials>    
</AddItemsRequest>

Response

<?xml version="1.0" encoding="UTF-8"?>  
<AddItemsResponse xmlns="urn:ebay:apis:eBLBaseComponents">  
  <Timestamp>2013-08-23T13:31:10.575Z</Timestamp>  
  <Ack>Failure</Ack>  
  <Errors>  
    <ShortMessage>Auth token is invalid.</ShortMessage>  
    <LongMessage>Validation of the authentication token in API request failed.</LongMessage>  
    <ErrorCode>931</ErrorCode>  
    <SeverityCode>Error</SeverityCode>  
    <ErrorClassification>RequestError</ErrorClassification>  
  </Errors>  
  <Version>833</Version>  
  <Build>E833_UNI_API5_16246498_R1</Build>  
</AddItemsResponse>
4

1 回答 1

2

您的请求的唯一错误是BuyItNowPrice元素对于FixedPriceItem列表无效。您需要将其更改为StartingPrice。除此之外,请求很好。我什至已将您的 XML 复制并粘贴到 eBay API 测试工具中,并且该项目已列出。http://cgi.sandbox.ebay.com/110121707611

在没有看到您如何使用 PHP 和 Curl 发送请求的情况下,我只能推荐以下内容。

  • 确保您将 POST 请求发送到正确的端点。
  • 如果请求字符串的开头有空格字符,则可能会出现问题。确保此字符串中的第一个字符是 XML 请求。
  • 确保 CURL 发送具有正确值的以下 HTTP 标头。
    • X-EBAY-API-兼容性级别:833
    • X-EBAY-API-DEV-NAME:[替换为您的 DEVID]
    • X-EBAY-API-APP-NAME:[替换为您的 APPID]
    • X-EBAY-API-CERT-NAME:[替换为您的证书]
    • X-EBAY-API-SITEID:2
    • X-EBAY-API-CALL-NAME:AddItems
于 2013-08-22T20:33:08.583 回答