Forum Moderators: open
Working with the Amazon web service
[webservices.amazon.com...]
I like to include a few more fields into my app, but I just can't find them, and don't know how to access them. I think I figured out which response groups I need. Here is a little snippet of my code.
The fields I am looking for are:
1.) ourprice
2.) percent off
3.) saleprice
and a few others.......
I also would like to change the search. For example: I would like to see all books that are >50% off.
And after that I am sure I have some questions concerning the shopping cart.
Please tell me you can help me.......I am going crazy.
Private Sub SendQueryToAmazon(ByVal pageNumber As String)
'clear datatable
dataTable.Rows.Clear()
'clear error label
errorMessageLabel.Text = ""
'build request to Amazon
itemSearch.SubscriptionId = Me.SubscriptionID
itemSearch.AssociateTag = Me.AssociateTag
itemSearchRequest.Keywords = searchTermTextBox.Text
itemSearchRequest.SearchIndex = "Blended"
itemSearchRequest.ItemPage = pageNumber
itemSearchRequest.ResponseGroup = New String() {"Large"}
itemSearchRequest.ResponseGroup = New String() {"Large", "Images"}
itemSearchRequest.ResponseGroup = New String() {"Large", "OfferListing"}
itemSearchRequest.ResponseGroup = New String() {"Large", "ItemAttributes"}
itemSearch.Request = New ItemSearchRequest() {itemSearchRequest}
'send the query
Try
itemSearchResponse = amazonService.ItemSearch(itemSearch)
Catch e As Exception
errorMessageLabel.Text = e.Message
Return
End Try
Dim itemsResponse() As Items = itemSearchResponse.Items
' Check for errors in the reponse
If (itemsResponse Is Nothing) Then
errorMessageLabel.Text = "Server Error"
Return
End If
If (Not (itemsResponse(0).Request.Errors) Is Nothing) Then
errorMessageLabel.Text = itemsResponse(0).Request.Errors(0).Message
Return
End If
If (Not (itemsResponse) Is Nothing) Then
'note that we only sent one request
'so we only have one response, which is the first
Dim items As Items = itemsResponse(0)
If (Not (items) Is Nothing) Then
'display total results
totalResultsLabelText.Visible = True
totalResultsLabel.Text = items.TotalResults
'need to set the total result for paging purposes
resultSetDataGrid.VirtualItemCount = [Convert].ToInt32(items.TotalResults)
Dim results() As Item = items.Item
If (Not (results) Is Nothing) Then
Dim enumerator As Collections.IEnumerator = CType(results, Collections.IEnumerable).GetEnumerator
Do While enumerator.MoveNext
Dim item As Item = CType(enumerator.Current, Item)
If (Not (item) Is Nothing) Then
'create a datarow, populate it and add it to the table
Dim dataRow As DataRow = dataTable.NewRow
If (Not (item.ItemAttributes.Title) Is Nothing) Then
dataRow("Title") = item.ItemAttributes.Title
End If
If (Not (item.ItemAttributes.Author) Is Nothing) Then
dataRow("Author") = item.ItemAttributes.Author(0)
End If
If (Not (item.ItemAttributes.ProductGroup) Is Nothing) Then
dataRow("ProductGroup") = item.ItemAttributes.ProductGroup
End If
If (Not (item.DetailPageURL) Is Nothing) Then
dataRow("AmazonURL") = item.DetailPageURL
End If
If (Not (item.SmallImage) Is Nothing) Then
dataRow("img") = item.SmallImage.URL
End If
If (Not (item.ItemAttributes.ListPrice) Is Nothing) Then
dataRow("price") = item.ItemAttributes.ListPrice.FormattedPrice
End If
dataTable.Rows.Add(dataRow)
End If
Dim dv As DataView = New DataView(dataTable)
'databinding the dataview to the datagrid
resultSetDataGrid.DataSource = dv
resultSetDataGrid.DataBind() Loop
End If
End If
End If
Return
End Sub
You'll find things a easier to debug that way, your code will be much more manageable, and best of all WebmasterWorld members will be able to help you more easily.
In order to fix your code as it stands, we'd need an example of the XML document you're getting from Amazon. However, even so, it's a lot of debugging work trying to understand your code, I doubt many WebmasterWorld mmbers have got that much time on their hands.