gsimchoni / ebayr

R wrapper to the ebay Finding API
2 stars 0 forks source link

There seems to be a problem with itemFilter representation in the constructed URL #1

Closed GitChub closed 6 years ago

GitChub commented 6 years ago

Thanks for creating this package! I was just trying it out and I think I discovered an issue.

I'm new to the eBay Finding API, but I found that your first example query resulted in an HTTP 500 error for me:

search_ebay(categoryName = "Video Game Consoles")

Note that in this example, the contents of the queryList are:

$categoryId
[1] 139971

$sortOrder
[1] "BestMatch"

$`itemFilter(12).name`
[1] "HideDuplicateItems"

$`itemFilter(12).value`
[1] "true"

$paginationInput.pageNumber
[1] 1

$paginationInput.entriesPerPage
[1] 10

I noticed that the "(12)" part after "itemFilter" makes it all the way into the constructed URL, but I don't think it is supposed to.

The addItemFilterToQuery function adds that parenthesized number with this line of code: queryList[[stringr::str_c("itemFilter(", itemFilterIdx, ").name")]] <- filterName

That parenthesized number is carried all the way through to the URL parameter, like this: &itemFilter%2812%29.name=HideDuplicateItems

However, I believe that URL parameter should look like this: &itemFilter.name=HideDuplicateItems

When I remove the occurrences of "(12)" from the URL, then I can successfully make the API call.

Does that make sense?

Also, I'm not as familiar with the eBay API as you are, but there was a particularly confusing thing I found in the package documentation and your blog post about the package. It makes repeated references to one's eBay "Token", but I found that the Token does not work, while the thing called (on eBay's site) the "AppID" or "AppID/ClientID" does work. Maybe an API Token can also be made to work somehow? Either way, it was confusing to me. I think it got me off on the wrong foot as I struggled for a while trying to get one of my Tokens to work, but, in the end, only my AppID seemed to work.

gsimchoni commented 6 years ago

Hello, first of all very sorry it took me so long to respond.

I am unable to replicate this. I installed a new version of R on a new laptop, installed Rstudio, re-installed from this source my own package, set my token, seems to work just fine. Can you tell if anything in your environment is different than mine?

res <- search_ebay(categoryName = "Video Game Consoles", returnAll = T)

res$queryList

$categoryId [1] 139971

$sortOrder [1] "BestMatch"

$itemFilter(0).name [1] "HideDuplicateItems"

$itemFilter(0).value [1] "true"

$paginationInput.pageNumber [1] 1

$paginationInput.entriesPerPage [1] 10

res$items

> # A tibble: 10 x 17
>    itemId  title   categoryId categoryName viewItemURL   location shippingType shipToLocations
>    <chr>   <chr>        <dbl> <chr>        <chr>         <chr>    <chr>        <chr>          
>  1 253536~ Xbox O~    139971. Video Game ~ http://www.e~ USA      Free         Worldwide      
>  2 282858~ NEW Pl~    139971. Video Game ~ http://www.e~ Fort Wo~ Free         Worldwide      
>  3 122976~ Xbox O~    139971. Video Game ~ http://www.e~ Atlanta~ Free         Worldwide      
>  4 321459~ Sony P~    139971. Video Game ~ http://www.e~ Port Ch~ Free         Worldwide      
>  5 192424~ " Sony~    139971. Video Game ~ http://www.e~ USA      Free         Worldwide      
>  6 142555~ N64 NI~    139971. Video Game ~ http://www.e~ Palm Ba~ Free         Worldwide      
>  7 292433~ Xbox O~    139971. Video Game ~ http://www.e~ Atlanta~ Free         Worldwide      
>  8 192513~ Micros~    139971. Video Game ~ http://www.e~ Glendal~ Free         Worldwide      
>  9 123016~ Xbox O~    139971. Video Game ~ http://www.e~ Atlanta~ Free         Worldwide      
> 10 302617~ Ninten~    139971. Video Game ~ http://www.e~ Atlanta~ Free         Worldwide      
> # ... with 9 more variables: isMultiVariationListing <lgl>, conditionId <dbl>,
> #   conditionName <chr>, listingType <chr>, startTime <date>, endTime <date>,
> #   watchCount <dbl>, price <dbl>, currency <chr>
sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Israel.1252  LC_CTYPE=English_Israel.1252   
[3] LC_MONETARY=English_Israel.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Israel.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ebayr_0.0.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16     rstudioapi_0.7   bindr_0.1.1      magrittr_1.5     devtools_1.13.5 
 [6] R6_2.2.2         rlang_0.2.0      stringr_1.3.0    httr_1.3.1       dplyr_0.7.4     
[11] tools_3.4.4      utf8_1.1.3       cli_1.0.0        git2r_0.21.0     withr_2.1.2     
[16] yaml_2.1.18      digest_0.6.15    assertthat_0.2.0 tibble_1.4.2     crayon_1.3.4    
[21] bindrcpp_0.2.2   purrr_0.2.4      curl_3.2         memoise_1.1.0    glue_1.2.0      
[26] stringi_1.1.7    compiler_3.4.4   pillar_1.2.1     jsonlite_1.5     pkgconfig_2.0.1
GitChub commented 6 years ago

No worries at all. Thank you for your reply Giora.

Well, this is a bit embarrassing. I cannot replicate the HTTP 500 error now. Hmmmm... I have changed some things since I reported the potential issue. I should have documented my environment at the time I encountered the error, but I didn't. I know I have installed/updated some packages since then (e.g. RCurl) and I believe I updated R to version 3.4.3 as well (on CentOS 7.2.1511). I've also restarted my RStudio session since then.

I'm not sure which of those changes may have been relevant to the HTTP 500 error I was encountering at first, but the error is gone now. I'm feeling a bit sheepish about this. Sorry for the distraction.

Update: BTW, I did notice that the first couple people who commented on your blog post at http://giorasimchoni.com/2017/12/19/2017-12-19-e-is-for-elephant-the-ebayr-package/ also mentioned encountering the same error that I encountered: "Error: ebay API request failed [500]". So, it seems there actually is something going on here. If I can manage to reproduce the error, I'll dig into it further.

gsimchoni commented 6 years ago

No embarrassment at all, if and when you see this - open this issue again with more details. Thank you.