VBA and Amazon API Integration

lewisgmorris

Board Regular
Joined
Oct 23, 2014
Messages
119
Can someone point me in the right direction to make this work?

GetLowestPricedOffersForASIN

I have all the keys i need and i'm trying to to use XMLHTTP60 lib to open the address http://mws.amazonservices.com?&ASIN=B00COK3FD8... etc but its not working.

Would anyone know what im doing wrong. I could be totally on the wrong track.


[h=2]Examples:[/h][h=3]Example query request[/h]POST /Products/2011-10-01 HTTP/1.1
Content-Type: x-www-form-urlencoded
Host: mws.amazonservices.com
User-Agent: <Your User Agent Header>

&ASIN=B00COK3FD8
&AWSAccessKeyId=AKIAEXAMPLEFWR4TJ7ZQ
&Action=GetLowestPricedOffersForASIN
&MWSAuthToken=amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE
&MarketplaceId=ATVPDKIKX0DER
&ItemCondition=New
&SellerId=A1IMEXAMPLEWRC
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2015-05-22T21%3A23%3A31Z
&Version=2011-10-01
&Signature=V1uTEXAMPLE8HVCfobAqQDKzylYyTRWfv3X4SEXAMPLEY%3D
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I've never used the API, but try something like this. Obviously you have to change the example key, auth token, seller Id, etc. to your own values, and probably the Timestamp to the current date-time.
Code:
Public Sub Test()

    Dim httpReq As XMLhttp, XMLdoc As DOMDocument  'requires reference to MS XML
    Dim POSTdata As String
    
    POSTdata = "&ASIN=B00COK3FD8" & _
        "&AWSAccessKeyId=AKIAEXAMPLEFWR4TJ7ZQ" & _
        "&Action=GetLowestPricedOffersForASIN" & _
        "&MWSAuthToken=amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE" & _
        "&MarketplaceId=ATVPDKIKX0DER" & _
        "&ItemCondition=New" & _
        "&SellerId=A1IMEXAMPLEWRC" & _
        "&SignatureMethod=HmacSHA256" & _
        "&SignatureVersion=2" & _
        "&Timestamp=2015-05-22T21%3A23%3A31Z" & _
        "&Version=2011-10-01" & _
        "&Signature=V1uTEXAMPLE8HVCfobAqQDKzylYyTRWfv3X4SEXAMPLEY%3D"

    Set httpReq = New XMLhttp
    With httpReq
        .Open "POST", "http://mws.amazonservices.com/Products/2011-10-01", False
        .setRequestHeader "Content-Type", "x-www-form-urlencoded"
        .setRequestHeader "Host", "mws.amazonservices.com"
        .setRequestHeader "User-Agent", "Excel VBA"
        .send POSTdata
        
        'Put XML response in a DOMDocument for parsing
        
        Set XMLdoc = .responseXML
        MsgBox XMLdoc.XML
    End With
    
    'Now parse the XML in XMLdoc using DOMDocument methods
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,453
Members
452,514
Latest member
cjkelly15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top