ropensci / openalexR

Getting bibliographic records from OpenAlex
https://docs.ropensci.org/openalexR/
Other
102 stars 21 forks source link

Can't use commas in title.search #254

Open hughjonesd opened 5 months ago

hughjonesd commented 5 months ago

The following code returns with a 403 error from openalex:

oa_fetch(title.search = "Hello, John", entity = "works")
Error: OpenAlex API request failed [403]
Invalid query parameters error.
<Invalid query parameter in  John.>

Using title.search = "\"Hello, John\"" gives the same error. So does pre-encoding it with utils::URLencode(). The openalex documentation isn't clear how to encode commas in search filters, so I'm not sure how to fix this.

Using search = "\"Hello, John\"" works OK, but this searches the abstract as well as the title.

trangdata commented 5 months ago

Thank you for reporting this @hughjonesd. You're right, the comma is currently reserved for separating the filters in the query. search = "\"Hello, John\"" works because in that case you're using search, not filter. The OpenAlex team is aware of this issue and hope to address it soon.