SQL Server
SQL Server
Walmart v3 Get All Feed Statuses
See more Walmart v3 Examples
Returns the feed statuses for all the specified Feed IDs.Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Implements the following CURL command:
-- curl -X GET \
-- https://marketplace.walmartapis.com/v3/feeds?feedId={feedId}&limit={limit}&offset={offset} \
-- -H 'WM_SVC.NAME: Walmart Marketplace'
-- -H 'WM_SEC.ACCESS_TOKEN: eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....'
-- -H 'WM_QOS.CORRELATION_ID: b3261d2d-028a-4ef7-8602-633c23200af6'
-- -H 'Content-Type: application/xml'
-- -H 'Accept: application/xml'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_QOS.CORRELATION_ID', 'b3261d2d-028a-4ef7-8602-633c23200af6'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/xml'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_SEC.ACCESS_TOKEN', 'eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/xml'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_SVC.NAME', 'Walmart Marketplace'
DECLARE @sbResponseBody int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://marketplace.walmartapis.com/v3/feeds?feedId={feedId}&limit={limit}&offset={offset}', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @xmlResponse int
EXEC @hr = sp_OACreate 'Chilkat.Xml', @xmlResponse OUT
EXEC sp_OAMethod @xmlResponse, 'LoadSb', @success OUT, @sbResponseBody, 1
-- Sample XML response:
-- (Sample code for parsing the XML response is shown below)
-- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-- <ns2:list xmlns:ns2="http://walmart.com/">
-- <ns2:totalResults>2</ns2:totalResults>
-- <ns2:offset>0</ns2:offset>
-- <ns2:limit>50</ns2:limit>
-- <ns2:results>
-- <ns2:feed>
-- <ns2:feedId>12234EGGT564YTEGFA@AQMBAQA</ns2:feedId>
-- <ns2:feedSource>MARKETPLACE_PARTNER</ns2:feedSource>
-- <ns2:feedType>item</ns2:feedType>
-- <ns2:partnerId>1413254255</ns2:partnerId>
-- <ns2:itemsReceived>1</ns2:itemsReceived>
-- <ns2:itemsSucceeded>1</ns2:itemsSucceeded>
-- <ns2:itemsFailed>0</ns2:itemsFailed>
-- <ns2:itemsProcessing>0</ns2:itemsProcessing>
-- <ns2:feedStatus>PROCESSED</ns2:feedStatus>
-- <ns2:feedDate>2018-07-20T21:56:12.605Z</ns2:feedDate>
-- <ns2:batchId>HP_REQUEST_BATCH</ns2:batchId>
-- <ns2:modifiedDtm>2018-07-20T21:56:17.948Z</ns2:modifiedDtm>
-- <ns2:fileName>ItemFeed99_ParadiseCounty_paperback.xml</ns2:fileName>
-- <ns2:itemDataErrorCount>0</ns2:itemDataErrorCount>
-- <ns2:itemSystemErrorCount>0</ns2:itemSystemErrorCount>
-- <ns2:itemTimeoutErrorCount>0</ns2:itemTimeoutErrorCount>
-- <ns2:channelType>WM_TEST</ns2:channelType>
-- </ns2:feed>
-- <ns2:feed>
-- <ns2:feedId>12234EGGT564YTEGFA@AQMBAQA</ns2:feedId>
-- <ns2:feedSource>MARKETPLACE_PARTNER</ns2:feedSource>
-- <ns2:feedType>item</ns2:feedType>
-- <ns2:partnerId>1413254255</ns2:partnerId>
-- <ns2:itemsReceived>1</ns2:itemsReceived>
-- <ns2:itemsSucceeded>1</ns2:itemsSucceeded>
-- <ns2:itemsFailed>0</ns2:itemsFailed>
-- <ns2:itemsProcessing>0</ns2:itemsProcessing>
-- <ns2:feedStatus>PROCESSED</ns2:feedStatus>
-- <ns2:feedDate>2018-07-20T21:56:12.605Z</ns2:feedDate>
-- <ns2:batchId>HP_REQUEST_BATCH</ns2:batchId>
-- <ns2:modifiedDtm>2018-07-20T21:56:17.948Z</ns2:modifiedDtm>
-- <ns2:fileName>ItemFeed99_ParadiseCounty_paperback.xml</ns2:fileName>
-- <ns2:itemDataErrorCount>0</ns2:itemDataErrorCount>
-- <ns2:itemSystemErrorCount>0</ns2:itemSystemErrorCount>
-- <ns2:itemTimeoutErrorCount>0</ns2:itemTimeoutErrorCount>
-- <ns2:channelType>WM_TEST</ns2:channelType>
-- </ns2:feed>
-- </ns2:results>
-- </ns2:list>
-- Sample code for parsing the XML response...
-- Use the following online tool to generate parsing code from sample XML:
-- Generate Parsing Code from XML
DECLARE @ns2_list_xmlns_ns2 nvarchar(4000)
DECLARE @ns2_totalResults int
DECLARE @ns2_offset int
DECLARE @ns2_limit int
DECLARE @i int
DECLARE @count_i int
DECLARE @ns2_feedId nvarchar(4000)
DECLARE @ns2_feedSource nvarchar(4000)
DECLARE @ns2_feedType nvarchar(4000)
DECLARE @ns2_partnerId int
DECLARE @ns2_itemsReceived int
DECLARE @ns2_itemsSucceeded int
DECLARE @ns2_itemsFailed int
DECLARE @ns2_itemsProcessing int
DECLARE @ns2_feedStatus nvarchar(4000)
DECLARE @ns2_feedDate nvarchar(4000)
DECLARE @ns2_batchId nvarchar(4000)
DECLARE @ns2_modifiedDtm nvarchar(4000)
DECLARE @ns2_fileName nvarchar(4000)
DECLARE @ns2_itemDataErrorCount int
DECLARE @ns2_itemSystemErrorCount int
DECLARE @ns2_itemTimeoutErrorCount int
DECLARE @ns2_channelType nvarchar(4000)
EXEC sp_OAMethod @xmlResponse, 'GetAttrValue', @ns2_list_xmlns_ns2 OUT, 'xmlns:ns2'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_totalResults OUT, 'ns2:totalResults'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_offset OUT, 'ns2:offset'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_limit OUT, 'ns2:limit'
SELECT @i = 0
EXEC sp_OAMethod @xmlResponse, 'NumChildrenHavingTag', @count_i OUT, 'ns2:results|ns2:feed'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @xmlResponse, 'I', @i
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_feedId OUT, 'ns2:results|ns2:feed[i]|ns2:feedId'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_feedSource OUT, 'ns2:results|ns2:feed[i]|ns2:feedSource'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_feedType OUT, 'ns2:results|ns2:feed[i]|ns2:feedType'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_partnerId OUT, 'ns2:results|ns2:feed[i]|ns2:partnerId'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemsReceived OUT, 'ns2:results|ns2:feed[i]|ns2:itemsReceived'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemsSucceeded OUT, 'ns2:results|ns2:feed[i]|ns2:itemsSucceeded'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemsFailed OUT, 'ns2:results|ns2:feed[i]|ns2:itemsFailed'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemsProcessing OUT, 'ns2:results|ns2:feed[i]|ns2:itemsProcessing'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_feedStatus OUT, 'ns2:results|ns2:feed[i]|ns2:feedStatus'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_feedDate OUT, 'ns2:results|ns2:feed[i]|ns2:feedDate'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_batchId OUT, 'ns2:results|ns2:feed[i]|ns2:batchId'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_modifiedDtm OUT, 'ns2:results|ns2:feed[i]|ns2:modifiedDtm'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_fileName OUT, 'ns2:results|ns2:feed[i]|ns2:fileName'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemDataErrorCount OUT, 'ns2:results|ns2:feed[i]|ns2:itemDataErrorCount'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemSystemErrorCount OUT, 'ns2:results|ns2:feed[i]|ns2:itemSystemErrorCount'
EXEC sp_OAMethod @xmlResponse, 'GetChildIntValue', @ns2_itemTimeoutErrorCount OUT, 'ns2:results|ns2:feed[i]|ns2:itemTimeoutErrorCount'
EXEC sp_OAMethod @xmlResponse, 'GetChildContent', @ns2_channelType OUT, 'ns2:results|ns2:feed[i]|ns2:channelType'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @xmlResponse
END
GO