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

httr2 doesn't seem to work for get_records(), but httr does #3

Closed
2 tasks
PietrH opened this issue Nov 10, 2023 · 1 comment · Fixed by #12
Closed
2 tasks

httr2 doesn't seem to work for get_records(), but httr does #3

PietrH opened this issue Nov 10, 2023 · 1 comment · Fixed by #12
Labels
bug Something isn't working

Comments

@PietrH
Copy link
Member

PietrH commented Nov 10, 2023

I'm used to writing my httr2 requests like this:

get_records <- function(inspection_name = "Vespa-Watch",
                        access_token = get_access_token(quiet = TRUE)) {
  # check input params
  assertthat::assert_that(assertthat::is.string(access_token))
  assertthat::assert_that(assertthat::is.string(inspection_name))
  # get the inspection_id for the custom inspection
  inspection_fields <- get_fields(access_token = access_token,
                                  name = inspection_name)
  # build a request and perform it
  get_records_request <-
    httr2::request("https://api.iasset.nl/getCustomInspections") %>%
    httr2::req_body_form(
      access_token = access_token,
      "inspection_ids[0]" = inspection_fields$id,
      version = "9.7"
    )
}

but it doesn't work, while this in httr does:

body = list(
  'access_token' = access_token,
  'version' = '9.7',
  'inspection_ids[0]' = inspection_fields$id
)

res <-
  httr::VERB(
    "POST",
    url = "https://api.iasset.nl/getCustomInspections",
    body = body,
    encode = 'multipart'
  )

# cat(content(res, 'text'))

res %>% httr::content()
  • is this a bug in httr2 ?
  • Is my httr2 code wrong?
@PietrH PietrH added the bug Something isn't working label Nov 10, 2023
@PietrH
Copy link
Member Author

PietrH commented Nov 13, 2023

Strangely, my original code seems to work for me today, and rather quickly too. Under 5 seconds. Very strange. I'll keep this open for now

@PietrH PietrH linked a pull request Nov 13, 2023 that will close this issue
11 tasks
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

Successfully merging a pull request may close this issue.

1 participant