PostcodesioR icon indicating copy to clipboard operation
PostcodesioR copied to clipboard

bulk_postcode_lookup vignette returns 400 error

Open jbl0ndie opened this issue 3 years ago • 3 comments

What

When user follows the vignette for bulk_postcode_lookup, Bad Request (HTTP 400) is returned, which is unexpected.

Steps to reproduce

  1. Install PostcodesioR
  2. Load library(PostcodesioR)
  3. Follow steps here: https://github.com/ropensci/PostcodesioR/blob/cdc196ee71dd6325b775d1fd82e40111c193bc19/vignettes/Introduction.Rmd#L56-L57
  4. Run
  5. See Warning message: In extract_results(r) : Bad Request (HTTP 400). printed in RStudio console

Other information

postcode_lookup("PR3 0SG"), postcode_lookup("M45 6GN") and postcode_lookup("EX165BL") returns the expected data for each single postcode

jbl0ndie avatar Feb 28 '22 23:02 jbl0ndie

Thanks for raising the issue. I can't recreate this error. 400 error suggests that the server was down at that time. Have you tried it again? Are you using the latest dev version (available on GitHub)? Similar issue (#15) has been reported in the past but it should be fixed now.

erykwalczak avatar Mar 07 '22 14:03 erykwalczak

Hi @erzk , Thanks for trying to recreate this. To the best of my knowledge, the issue is here:

https://github.com/ropensci/PostcodesioR/blob/cdc196ee71dd6325b775d1fd82e40111c193bc19/R/bulk_postcode_lookup.R#L25-L32

If I replace lapply(postcodes, URLencode) with lapply(postcodes, paste0) I get the response as expected. I don't think the body needs URLencoding. I was going to make you a PR later today, if I get time.

jbl0ndie avatar Mar 07 '22 16:03 jbl0ndie

Thanks for finding a solution. I'm not sure if removing URLencode is the best approach as the lack of it was causing issues in the past - see #14

erykwalczak avatar Mar 07 '22 16:03 erykwalczak