MarkEdmondson1234 / searchConsoleR

R interface with Google Search Console API v3, including Search Analytics.
http://code.markedmondson.me/searchConsoleR/
Other
114 stars 41 forks source link

Error: discover "API Data failed to parse." #75

Open Petervg1993 opened 2 years ago

Petervg1993 commented 2 years ago

What goes wrong

The library works great, but since a few weeks, when I use the searchTypes "discover" or "googleNews". I get an error. Thanks in advance!!! Remark:

Steps to reproduce the problem

mydataset <- search_analytics(siteURL = "https://www.XXXXX.com/"
                              ,startDate = "2022-03-02"
                              ,endDate = "2022-03-02"
                              ,dimensions = c("date", "page")
                              ,searchType = "discover"
                              ,rowLimit = 1000
                              ,walk_data = "byBatch")

Expected output

A data.frame with the discover information

Actual output

> options(googleAuthR.verbose=2)
> 
> mydataset <- search_analytics(siteURL = "XXX",startDate = "2022-01-02",endDate = "2022-01-02",dimensions = c("date", "page"),searchType = "discover",rowLimit = 1000 ,walk_data = "byBatch")
Fetching search analytics for url: https://www.XXX.com/ dates: 2022-01-02 2022-01-02 dimensions: date page dimensionFilterExp:  searchType: discover aggregationType: auto
ℹ 2022-03-07 17:51:23 > Token exists.
ℹ 2022-03-07 17:51:23 > Request:  https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fwww.XXX.com%2F/searchAnalytics/query
ℹ 2022-03-07 17:51:23 > Body JSON parsed to:  {"startDate":"2022-01-02","endDate":"2022-01-02","dimensions":["date","page"],"type":"discover","dimensionFilterGroups":[{"groupType":"and","filters":[]}],"aggregationType":"auto","rowLimit":1000}
Error in `$<-.data.frame`(`*tmp*`, "position", value = numeric(0)) : 
  replacement has 0 rows, data has 10
Erreur : API Data failed to parse.  
             Wrote diagnostic object to 'gar_parse_error.rds', use googleAuthR::gar_debug_parsing('gar_parse_error.rds') to 
             debug the data_parse_function.

When running "googleAuthR::gar_debug_parsing('gar_parse_error.rds')" i get this:

$response$content
$response$content$rows
   keys
1                         2022-01-02, https://www.XXX.com/XXX
2                                           2022-01-02, https://www.XXX.com/XXX
3  2022-01-02, https://www.XXX.com/XXX
4                        2022-01-02, https://www.XXX.com/XXX
5               2022-01-02, https://www.XXX.com/XXX
6                                  2022-01-02, https://www.XXX.com/XXX
7                                            2022-01-02, https://www.XXX.com/XXX
8                                             2022-01-02, https://www.XXX.com/XXX
9                                            2022-01-02, https://www.XXX.com/XXX
10                              2022-01-02, https://www.XXX.com/XXX
   clicks impressions        ctr
1    2010       25898 0.07761217
2    1420       23472 0.06049761
3    1117       14444 0.07733315
4     841        7617 0.11041092
5     178        4710 0.03779193
6     111        4190 0.02649165
7     109        3113 0.03501446
8      80        3947 0.02026856
9      36         689 0.05224964
10     19         135 0.14074074

$response$content$responseAggregationType
[1] "byPage"`

$authentication
$authentication$token
<Token>
<oauth_endpoint>
 authorize: https://accounts.google.com/o/oauth2/auth
 access:    https://accounts.google.com/o/oauth2/token
 validate:  https://www.googleapis.com/oauth2/v1/tokeninfo
 revoke:    https://accounts.google.com/o/oauth2/revoke
NULL
<credentials> access_token, expires_in, token_type
---

attr(,"class")
[1] "gar_parse_error"

Session Info

Please run sessionInfo() so we can check what versions of packages you have installed

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: OS X  12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

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

other attached packages:
 [1] RJSONIO_1.3-1.4           rjson_0.2.20              googleAuthR_2.0.0         searchConsoleR_0.4.0.9000 urltools_1.7.3            rlang_1.0.2               gargle_1.2.0             
 [8] bigrquery_1.3.2           googlesheets4_0.2.0       googledrive_1.0.1         forcats_0.5.0             stringr_1.4.0             dplyr_1.0.2               purrr_0.3.4              
[15] readr_1.4.0               tidyr_1.1.2               tibble_3.0.3              ggplot2_3.3.2             tidyverse_1.3.0          

loaded via a namespace (and not attached):
 [1] progress_1.2.2    tidyselect_1.1.0  haven_2.3.1       colorspace_1.4-1  vctrs_0.3.8       generics_0.0.2    blob_1.2.1        pillar_1.4.6      glue_1.6.2        withr_2.5.0      
[11] DBI_1.1.0         rappdirs_0.3.3    bit64_4.0.5       dbplyr_1.4.4      modelr_0.1.8      readxl_1.3.1      lifecycle_0.2.0   munsell_0.5.0     gtable_0.3.0      cellranger_1.1.0 
[21] rvest_0.3.6       memoise_2.0.1     fastmap_1.1.0     curl_4.3.2        triebeard_0.3.0   broom_0.7.1       Rcpp_1.0.6        openssl_2.0.0     scales_1.1.1      backports_1.2.1  
[31] cachem_1.0.6      jsonlite_1.8.0    fs_1.5.2          bit_4.0.4         hms_0.5.3         askpass_1.1       digest_0.6.29     stringi_1.7.6     grid_4.0.2        cli_3.2.0        
[41] tools_4.0.2       magrittr_2.0.2    crayon_1.3.4      pkgconfig_2.0.3   ellipsis_0.3.2    prettyunits_1.1.1 xml2_1.3.2        reprex_0.3.0      lubridate_1.7.9   assertthat_0.2.1 
[51] httr_1.4.2        rstudioapi_0.13   R6_2.5.1          compiler_4.0.2