Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request 'id = 1' failed: Status 400. #73

Closed
cris-silva opened this issue Oct 17, 2020 · 6 comments
Closed

Request 'id = 1' failed: Status 400. #73

cris-silva opened this issue Oct 17, 2020 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@cris-silva
Copy link

cris-silva commented Oct 17, 2020

Hi!

I'm using reverse_geocode() to bring back address from coordinates. But when I'm using the same script and API key on another computer I get the Request 'id = 1' failed: Status 400.

Update: I tried to install an older version (0.4.1) and works fine. I guess something related to API URL.

@munterfi
Copy link
Owner

Hi, thanks for reporting.

Indeed the API version has changed with the release of hereR v0.5.0 from Geocoder API v6.2 to Geocoder API v7.

I am able to reconstruct the issue:

library(hereR)
set_verbose(TRUE)
reverse_geocode(poi[1, ])
#> Sending 1 request(s) to: 'https://revgeocode.search.hereapi.com/v1/revgeocode?...'
#> Warning in (function (res) : Request 'id = 1' failed: Status 400.
#> Received 0 response(s) with total size: 48 bytes
#> NULL

It seems to be a problem concerning the parameter name of the api key (&apiKey=) in the request, as the response of the API is suggesting:

{
    "status": 400,
    "title": "Illegal input for parameter 'no-name parameter'",
    "cause": "Actual parameter value: ''",
    "action": "Query parameters must have a name",
    "correlationId": "75720ac0-f85d-46d4-8118-059b9e9948a3",
    "requestId": "REQ-80279383-9502-489c-b16f-50087a00f07c"
}

The other endpoints on the Geocoder API also fail:

geocode("Scheighofstrasse 190, Zürich")
#> Sending 1 request(s) to: 'https://geocode.search.hereapi.com/v1/geocode?...'
#> Warning in (function (res) : Request 'id = 1' failed: Status 400.
#> Received 0 response(s) with total size: 48 bytes
#> NULL
autosuggest("Scheighofstrasse 190, Zürich")
#> Sending 1 request(s) to: 'https://revgeocode.search.hereapi.com/v1/autosuggest?...'
#> Warning in (function (res) : Request 'id = 1' failed: Status 400.
#> Received 0 response(s) with total size: 48 bytes
#> NULL

The key is still working on other APIs, e.g. the Public Transit API, which was also updated to a newer version in release of v0.5.0:

connection(poi[1, ], poi[2, ])
#> Sending 1 request(s) to: 'https://transit.router.hereapi.com/v8/routes?...'
#> Received 1 response(s) with total size: 55.5 Kb
#> Simple feature collection with 23 features and 13 fields
#> geometry type:  LINESTRING
#> dimension:      XY
#> bbox:           xmin: 8.274078 ymin: 46.00292 xmax: 9.04178 ymax: 47.14558
#> geographic CRS: WGS 84
#> First 10 features:
#>    id rank           departure                     origin             arrival
#> 1   1    1 2020-10-18 15:23:00                       ORIG 2020-10-18 15:31:00
#> 2   1    1 2020-10-18 15:31:00         Littau, Längweiher 2020-10-18 15:51:00
#> 3   1    1 2020-10-18 15:51:00            Ebikon, Bahnhof 2020-10-18 15:52:00
#> 4   1    1 2020-10-18 15:58:00                     Ebikon 2020-10-18 16:08:00
#> 5   1    1 2020-10-18 16:16:00                   Rotkreuz 2020-10-18 17:56:00
#> 6   1    1 2020-10-18 17:56:00                     Lugano 2020-10-18 18:00:00
#> 7   1    1 2020-10-18 18:07:00           Lugano, Stazione 2020-10-18 18:20:00
#> 8   1    1 2020-10-18 18:20:00 Castagnola, Villa Favorita 2020-10-18 18:21:00
#> 9   1    2 2020-10-18 15:50:00                       ORIG 2020-10-18 15:58:00
#> 10  1    2 2020-10-18 15:58:00         Littau, Längweiher 2020-10-18 16:09:00
#>                   destination           mode        category vehicle
#> 1          Littau, Längweiher     pedestrian            <NA>    <NA>
#> 2             Ebikon, Bahnhof            bus             Bus      30
#> 3                      Ebikon     pedestrian            <NA>    <NA>
#> 4                    Rotkreuz      cityTrain           Train     S 1
#> 5                      Lugano intercityTrain Intercity Train    IC 2
#> 6            Lugano, Stazione     pedestrian            <NA>    <NA>
#> 7  Castagnola, Villa Favorita            bus             Bus       2
#> 8                        DEST     pedestrian            <NA>    <NA>
#> 9          Littau, Längweiher     pedestrian            <NA>    <NA>
#> 10            Luzern, Bahnhof            bus             Bus      12
#>                           provider             direction distance duration
#> 1                             <NA>                  <NA>      473      480
#> 2   vbl verkehrsbetriebe luzern ag       Ebikon, Bahnhof     6849     1200
#> 3                             <NA>                  <NA>       60       60
#> 4  Schweizerische Bundesbahnen SBB                  Baar     9558      600
#> 5  Schweizerische Bundesbahnen SBB                Lugano   156542     6000
#> 6                             <NA>                  <NA>      240      240
#> 7      Trasporti Pubblici Luganesi Castagnola, Capolinea     3100      780
#> 8                             <NA>                  <NA>       46       60
#> 9                             <NA>                  <NA>      473      480
#> 10  vbl verkehrsbetriebe luzern ag       Luzern, Bahnhof     4264      660
#>                          geometry
#> 1  LINESTRING (8.278885 47.050...
#> 2  LINESTRING (8.274078 47.051...
#> 3  LINESTRING (8.342609 47.084...
#> 4  LINESTRING (8.342351 47.084...
#> 5  LINESTRING (8.431161 47.142...
#> 6  LINESTRING (8.946987 46.005...
#> 7  LINESTRING (8.94742 46.0050...
#> 8  LINESTRING (8.971271 46.003...
#> 9  LINESTRING (8.278885 47.050...
#> 10 LINESTRING (8.274078 47.051...

Please use v0.4.1 of hereR until this is fixed.

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       macOS Catalina 10.15.7      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Zurich               
#>  date     2020-10-18                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date       lib source        
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.0.0)
#>  backports      1.1.10     2020-09-15 [1] CRAN (R 4.0.2)
#>  callr          3.4.4      2020-09-07 [1] CRAN (R 4.0.2)
#>  class          7.3-17     2020-04-26 [1] CRAN (R 4.0.2)
#>  classInt       0.4-3      2020-04-07 [1] CRAN (R 4.0.0)
#>  cli            2.0.2      2020-02-28 [1] CRAN (R 4.0.0)
#>  crayon         1.3.4      2017-09-16 [1] CRAN (R 4.0.0)
#>  curl           4.3        2019-12-02 [1] CRAN (R 4.0.1)
#>  data.table     1.13.0     2020-07-24 [1] CRAN (R 4.0.2)
#>  DBI            1.1.0      2019-12-15 [1] CRAN (R 4.0.0)
#>  desc           1.2.0      2018-05-01 [1] CRAN (R 4.0.0)
#>  devtools       2.3.2      2020-09-18 [1] CRAN (R 4.0.2)
#>  digest         0.6.25     2020-02-23 [1] CRAN (R 4.0.0)
#>  dplyr          1.0.2      2020-08-18 [1] CRAN (R 4.0.2)
#>  e1071          1.7-3      2019-11-26 [1] CRAN (R 4.0.0)
#>  ellipsis       0.3.1      2020-05-15 [1] CRAN (R 4.0.0)
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.0.0)
#>  fansi          0.4.1      2020-01-08 [1] CRAN (R 4.0.0)
#>  flexpolyline   0.1.1.9000 2020-08-29 [1] local         
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.0.2)
#>  generics       0.0.2      2018-11-29 [1] CRAN (R 4.0.0)
#>  glue           1.4.2      2020-08-27 [1] CRAN (R 4.0.2)
#>  hereR        * 0.5.0      2020-09-18 [1] CRAN (R 4.0.2)
#>  htmltools      0.5.0      2020-06-16 [1] CRAN (R 4.0.2)
#>  jsonlite       1.7.1      2020-09-07 [1] CRAN (R 4.0.2)
#>  KernSmooth     2.23-17    2020-04-26 [1] CRAN (R 4.0.2)
#>  knitr          1.30       2020-09-22 [1] CRAN (R 4.0.2)
#>  lifecycle      0.2.0      2020-03-06 [1] CRAN (R 4.0.0)
#>  magrittr       1.5        2014-11-22 [1] CRAN (R 4.0.0)
#>  memoise        1.1.0      2017-04-21 [1] CRAN (R 4.0.0)
#>  pillar         1.4.6      2020-07-10 [1] CRAN (R 4.0.2)
#>  pkgbuild       1.1.0      2020-07-13 [1] CRAN (R 4.0.2)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.0.0)
#>  pkgload        1.1.0      2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits    1.1.1      2020-01-24 [1] CRAN (R 4.0.0)
#>  processx       3.4.4      2020-09-03 [1] CRAN (R 4.0.2)
#>  ps             1.3.4      2020-08-11 [1] CRAN (R 4.0.2)
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.0.0)
#>  R6             2.4.1      2019-11-12 [1] CRAN (R 4.0.0)
#>  Rcpp           1.0.5      2020-07-06 [1] CRAN (R 4.0.2)
#>  remotes        2.2.0      2020-07-21 [1] CRAN (R 4.0.2)
#>  rlang          0.4.7      2020-07-09 [1] CRAN (R 4.0.2)
#>  rmarkdown      2.4        2020-09-30 [1] CRAN (R 4.0.2)
#>  rprojroot      1.3-2      2018-01-03 [1] CRAN (R 4.0.0)
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 4.0.0)
#>  sf             0.9-6      2020-09-13 [1] CRAN (R 4.0.2)
#>  stringi        1.5.3      2020-09-09 [1] CRAN (R 4.0.2)
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.0.2)
#>  testthat       2.3.2      2020-03-02 [1] CRAN (R 4.0.2)
#>  tibble         3.0.3      2020-07-10 [1] CRAN (R 4.0.2)
#>  tidyselect     1.1.0      2020-05-11 [1] CRAN (R 4.0.0)
#>  units          0.6-7      2020-06-13 [1] CRAN (R 4.0.2)
#>  usethis        1.6.3      2020-09-17 [1] CRAN (R 4.0.2)
#>  vctrs          0.3.4      2020-08-29 [1] CRAN (R 4.0.2)
#>  withr          2.3.0      2020-09-22 [1] CRAN (R 4.0.2)
#>  xfun           0.18       2020-09-29 [1] CRAN (R 4.0.2)
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.0.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

@munterfi munterfi self-assigned this Oct 18, 2020
@munterfi munterfi added the bug Something isn't working label Oct 18, 2020
@munterfi
Copy link
Owner

This should be fixed now.

Release of hereR 0.5.1 is submitted to CRAN and should be available in the next days. Until then you can use the dev version from GitHub: remotes::install_github("munterfinger/hereR")

@cris-silva
Copy link
Author

This should be fixed now.

Release of hereR 0.5.1 is submitted to CRAN and should be available in the next days. Until then you can use the dev version from GitHub: remotes::install_github("munterfinger/hereR")

Thank you! The new version works well. Great work with this library!

@jaimeorrego
Copy link

jaimeorrego commented Jan 16, 2021

Hello,
Thanks for the package and development. I am experiencing this error again. In the web browser, the call using the url from url_only = TRUE works fine. However, using geocode in R gives me again the
Warning in (function (res) : Request 'id = 1' failed: Status 400.
What could be the problem?

Thanks!

Edit: Nevermind, it does not work with Spanish characters like ñ, once you take them out, it works fine.

@munterfi
Copy link
Owner

Hi, thanks for the feedback.

Which version of the package are you using? With the current version 0.6.0 on CRAN everything works fine, also with special characters like ñ:

library(hereR)
set_verbose(TRUE)
geocode(
  c(
    "A Coruña, España",
    "Genève, Suisse",
    "Бишкек, Киргизстан",
    "東京",
    "Reykjavík, Ísland",
    "Bogotá, Colombia"
  )
)
#> Sending 6 request(s) to: 'https://geocode.search.hereapi.com/v1/geocode?...'
#> Received 6 response(s) with total size: 4 Kb
#> Simple feature collection with 6 features and 15 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -74.06941 ymin: 4.61496 xmax: 139.8088 ymax: 64.14585
#> geographic CRS: WGS 84
#>   id rank                   address     type street house_number postal_code
#> 1  1    1 A Coruña, Galicia, España locality   <NA>         <NA>       15003
#> 2  2    1            Genève, Suisse locality   <NA>         <NA>        1201
#> 3  3    1       Bishkek, Kyrgyzstan locality   <NA>         <NA>        <NA>
#> 4  4    1                 Japan東京 locality   <NA>         <NA>        <NA>
#> 5  5    1   Reykjavíkurborg, Ísland locality   <NA>         <NA>         101
#> 6  6    1    Bogotá, D.C., Colombia locality   <NA>         <NA>      110311
#>   state_code country_code district            city            county   state
#> 1         GA          ESP     <NA>        A Coruña          A Coruña Galicia
#> 2         GE          CHE     <NA>          Genève            Genève  Genève
#> 3       <NA>          KGZ     <NA>         Bishkek           Bishkek    <NA>
#> 4       <NA>          JPN     <NA>            東京             Japan    <NA>
#> 5       <NA>          ISL     <NA> Reykjavíkurborg Höfuðborgarsvæðið    <NA>
#> 6       <NA>          COL     <NA>    Bogotá, D.C.      Bogotá, D.C.    <NA>
#>      country      access                   geometry
#> 1     España POINT EMPTY   POINT (-8.4021 43.36846)
#> 2     Suisse POINT EMPTY   POINT (6.14275 46.20833)
#> 3 Kyrgyzstan POINT EMPTY  POINT (74.60354 42.88434)
#> 4       日本 POINT EMPTY  POINT (139.8089 35.68408)
#> 5     Ísland POINT EMPTY POINT (-21.93955 64.14585)
#> 6   Colombia POINT EMPTY  POINT (-74.06941 4.61496)
Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.3 (2020-10-10)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Zurich               
#>  date     2021-01-16                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.0)
#>  callr         3.5.1   2020-10-13 [1] CRAN (R 4.0.2)
#>  class         7.3-17  2020-04-26 [1] CRAN (R 4.0.3)
#>  classInt      0.4-3   2020-04-07 [1] CRAN (R 4.0.0)
#>  cli           2.2.0   2020-11-20 [1] CRAN (R 4.0.2)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 4.0.0)
#>  curl          4.3     2019-12-02 [1] CRAN (R 4.0.1)
#>  data.table    1.13.4  2020-12-08 [1] CRAN (R 4.0.2)
#>  DBI           1.1.0   2019-12-15 [1] CRAN (R 4.0.2)
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 4.0.0)
#>  devtools      2.3.2   2020-09-18 [1] CRAN (R 4.0.2)
#>  digest        0.6.27  2020-10-24 [1] CRAN (R 4.0.2)
#>  dplyr         1.0.2   2020-08-18 [1] CRAN (R 4.0.2)
#>  e1071         1.7-4   2020-10-14 [1] CRAN (R 4.0.2)
#>  ellipsis      0.3.1   2020-05-15 [1] CRAN (R 4.0.0)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.0)
#>  fansi         0.4.1   2020-01-08 [1] CRAN (R 4.0.0)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
#>  generics      0.1.0   2020-10-31 [1] CRAN (R 4.0.2)
#>  glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  hereR       * 0.6.0   2021-01-04 [1] CRAN (R 4.0.2)
#>  htmltools     0.5.0   2020-06-16 [1] CRAN (R 4.0.2)
#>  jsonlite      1.7.2   2020-12-09 [1] CRAN (R 4.0.2)
#>  KernSmooth    2.23-18 2020-10-29 [1] CRAN (R 4.0.2)
#>  knitr         1.30    2020-09-22 [1] CRAN (R 4.0.2)
#>  lifecycle     0.2.0   2020-03-06 [1] CRAN (R 4.0.0)
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.0.2)
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 4.0.0)
#>  pillar        1.4.7   2020-11-20 [1] CRAN (R 4.0.2)
#>  pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.0.2)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.0.0)
#>  pkgload       1.1.0   2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.0.0)
#>  processx      3.4.5   2020-11-30 [1] CRAN (R 4.0.2)
#>  ps            1.5.0   2020-12-05 [1] CRAN (R 4.0.2)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.0.0)
#>  R6            2.5.0   2020-10-28 [1] CRAN (R 4.0.2)
#>  Rcpp          1.0.5   2020-07-06 [1] CRAN (R 4.0.2)
#>  remotes       2.2.0   2020-07-21 [1] CRAN (R 4.0.2)
#>  rlang         0.4.9   2020-11-26 [1] CRAN (R 4.0.2)
#>  rmarkdown     2.6     2020-12-14 [1] CRAN (R 4.0.2)
#>  rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.0.2)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.0)
#>  sf            0.9-7   2021-01-06 [1] CRAN (R 4.0.3)
#>  stringi       1.5.3   2020-09-09 [1] CRAN (R 4.0.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
#>  testthat      3.0.1   2020-12-17 [1] CRAN (R 4.0.2)
#>  tibble        3.0.4   2020-10-12 [1] CRAN (R 4.0.2)
#>  tidyselect    1.1.0   2020-05-11 [1] CRAN (R 4.0.0)
#>  units         0.6-7   2020-06-13 [1] CRAN (R 4.0.2)
#>  usethis       2.0.0   2020-12-10 [1] CRAN (R 4.0.2)
#>  vctrs         0.3.6   2020-12-17 [1] CRAN (R 4.0.2)
#>  withr         2.3.0   2020-09-22 [1] CRAN (R 4.0.2)
#>  xfun          0.19    2020-10-30 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

@jaimeorrego
Copy link

Sorry for the delayed response, I thought I have answered, but it seems I did not submit it. I believe that maybe has something to do with my r studio configuration or the system language. Because I tried putting the URL directly httr and it did not work either.
If I manage to realize what happen I will let you know.
And thanks for the response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants