Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Amazon AIM Upload InventoryDemonstrates how to upload an inventory management file using the Amazon Inventory Management (AIM) API. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @req int EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Any string unlocks the component for the 1st 30-days. EXEC sp_OAMethod @http, 'UnlockComponent', @success OUT, 'Anything for 30-day trial' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- The CookieDir may be set to "memory" to keep an in-memory cache of cookies. -- Alternatively, you may set it to a directory, such as "c:/temp/cookies". If you do that, -- you can visually browse the cookies which will appear as XML files in the CookieDir. EXEC sp_OASetProperty @http, 'CookieDir', 'memory' -- Tell the HTTP component to save any cookies received. Also tell the component to -- re-send cookies with subsequent GETs and POSTs. EXEC sp_OASetProperty @http, 'SendCookies', 1 EXEC sp_OASetProperty @http, 'SaveCookies', 1 -- Build an HTTP upload request: EXEC sp_OAMethod @req, 'UseUpload', NULL -- The path may be one of these 3 choices: -- /exec/panama/seller-admin/catalog-upload/add-modify-delete -- /exec/panama/seller-admin/catalog-upload/modify-only -- /exec/panama/seller-admin/catalog-upload/purge-replace EXEC sp_OASetProperty @req, 'Path', '/exec/panama/seller-admin/catalog-upload/add-modify-delete' -- Load the inventory file into the HTTPS request: EXEC sp_OAMethod @req, 'AddFileForUpload', @success OUT, 'myInventory', 'myInventory.txt' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @req, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Setting your login/password causes Chilkat to automatically add the Authorization header: EXEC sp_OASetProperty @http, 'Login', 'YourLoginEmailAddress' EXEC sp_OASetProperty @http, 'Password', 'YourPassword' -- call req.AddHeader("BatchID", "Y"); EXEC sp_OAMethod @req, 'AddHeader', NULL, 'FileFormat', 'TabDelimited' EXEC sp_OAMethod @req, 'AddHeader', NULL, 'UploadFor', 'MarketplaceOnly' -- Send the HTTP POST and get the response. Note: This is a blocking call. -- The method does not return until the full HTTP response is received. DECLARE @domain nvarchar(4000) DECLARE @port int DECLARE @ssl int SELECT @domain = 'merchant-query.amazon.com' SELECT @port = 443 SELECT @ssl = 1 DECLARE @resp int EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, @domain, @port, @ssl, @req IF @resp Is NULL BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END ELSE BEGIN -- Display the XML returned. EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT PRINT @sTmp0 END END GO |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.