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

hasImages parameter acts odd due to Python having upper-case Booleans` #48

Open
HStep20 opened this issue Apr 1, 2024 · 1 comment
Open

Comments

@HStep20
Copy link

HStep20 commented Apr 1, 2024

I was making some request calls to the 'search' endpoint to get some information about paintings, and noticed some very odd behavior regarding the hasImages field. When encoding data via the requests library, the upper case 'T' in 'True' causes issues with the case sensitive nature of the hasImages field. You can see here that there is quite a large difference between manually encoding data and letting the library encode that data for you

Manual Encoding (12111 results):

object_ids_large = session.get(BASE_URL+"/search?hasImages=true&medium=Paintings&q=%22%22").json()

Requests Library Encoding (228 results):

object_ids_small = session.get(BASE_URL+"/search", params={ "hasImages" : True, "medium" : "Paintings","q":""}).json()

I had tried using a string in my params (passing "true"), but that returned 0 results, so however this boolean is interpreted on the backend query behaves strange across languages.

@DaxServer
Copy link

@HStep20 It is because in the first query the param q is set to %22%22 as a string while in the second the q is set to an empty string and thus will be encoded to `` (nothing). The resultant urls are

  1. https://collectionapi.metmuseum.org/public/collection/v1/search?hasImages=true&medium=Paintings&q=%22%22
  2. https://collectionapi.metmuseum.org/public/collection/v1/search?hasImages=True&medium=Paintings&q=

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