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

bulk_postcode_lookup vignette returns 400 error #16

Open
jbl0ndie opened this issue Feb 28, 2022 · 3 comments
Open

bulk_postcode_lookup vignette returns 400 error #16

jbl0ndie opened this issue Feb 28, 2022 · 3 comments

Comments

@jbl0ndie
Copy link

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:
    pc_list <- list(postcodes = c("PR3 0SG", "M45 6GN", "EX165BL"))
    bulk_lookup_result <- bulk_postcode_lookup(pc_list)
  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

@erykwalczak
Copy link
Member

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.

@jbl0ndie
Copy link
Author

jbl0ndie commented Mar 7, 2022

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

bulk_postcode_lookup <- function(postcodes) {
check_list_limit(postcodes)
postcodes <- lapply(postcodes, URLencode)
r <- POST("https://api.postcodes.io/postcodes",
body = postcodes,
encode = "json")
extract_results(r)
}

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.

@erykwalczak
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants