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

Error: lexical error: invalid char in json text when using oa_fetch #229

Open
jcortesanchez opened this issue Apr 11, 2024 · 1 comment
Open

Comments

@jcortesanchez
Copy link

Dear openalexR team, I'm trying to get bibliographic data from Argentina (ar) and other countries using the oa_fetch function:

works_ar <- oa_fetch(
entity = "works",
authorships.institutions.country_code = "ar",
verbose = TRUE
)

However I'm still getting this error:

Error: lexical error: invalid char in json text.
<?xml version="1.0" encoding="u
(right here) ------^

Thanks for your help.

@trangdata
Copy link
Collaborator

@jcortesanchez Hmm that is almost 500,000 works you're trying to download (~2500 API calls)... Is there a more specific filter you can use? If you need all works and will do this for other countries, I recommend downloading the snapshot.

As for this particular error, I'm having trouble getting a minimal example to reproduce it. If I only look at the first 1000 works, it seems to work fine:

library(openalexR)
works_ar <- oa_fetch(
  entity = "works",
  authorships.institutions.country_code = "ar",
  pages = 1:5,
  verbose = TRUE
)
#> Requesting url: https://api.openalex.org/works?filter=authorships.institutions.country_code%3Aar
#> Using basic paging...
#> Getting 5 pages of results with a total of 1000 records...
works_ar
#> # A tibble: 1,000 × 38
#>    id               title display_name author ab    publication_date so    so_id
#>    <chr>            <chr> <chr>        <list> <chr> <chr>            <chr> <chr>
#>  1 https://openale… The … The value o… <df>    <NA> 1997-05-01       "Nat… http…
#>  2 https://openale… Dabi… Dabigatran … <df>   "War… 2009-09-17       "New… http…
#>  3 https://openale… The … The Clavien… <df>   "In … 2009-08-01       "Ann… http…
#>  4 https://openale… Glob… Global Biod… <df>   "Sce… 2000-03-10       "Sci… http…
#>  5 https://openale… Apix… Apixaban ve… <df>   "Vit… 2011-09-15       "New… http…
#>  6 https://openale… Mini… Minimal inf… <df>   "The… 2018-11-23       "Jou… http…
#>  7 https://openale… Anti… Antiinflamm… <df>   "Exp… 2017-09-21       "New… http…
#>  8 https://openale… A gl… A global ov… <df>   "Gre… 2010-02-01       "For… http…
#>  9 https://openale… Rosu… Rosuvastati… <df>   "Inc… 2008-11-20       "\u0… http…
#> 10 https://openale… Erlo… Erlotinib i… <df>   "We … 2005-07-14       "\u0… http…
#> # ℹ 990 more rows
#> # ℹ 30 more variables: host_organization <chr>, issn_l <chr>, url <chr>,
#> #   pdf_url <chr>, license <chr>, version <chr>, first_page <chr>,
#> #   last_page <chr>, volume <chr>, issue <chr>, is_oa <lgl>,
#> #   is_oa_anywhere <lgl>, oa_status <chr>, oa_url <chr>,
#> #   any_repository_has_fulltext <lgl>, language <chr>, grants <list>,
#> #   cited_by_count <int>, counts_by_year <list>, publication_year <int>, …

Created on 2024-04-11 with reprex v2.0.2

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