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

Invalid query error when using simplified version of your code #17

Closed
baskaufs opened this issue Feb 22, 2023 · 1 comment
Closed

Invalid query error when using simplified version of your code #17

baskaufs opened this issue Feb 22, 2023 · 1 comment

Comments

@baskaufs
Copy link

Hi @jvfe. Thanks so much for posting this. I had been searching all over the web for some examples and didn't find the OpenRefine or Reconcilliation Service API W3C Community Report particularly helpful for getting the wikidata.reconci.link API to work in Python. Using your code here and the Reconcilliation Service example for a reconciliation query, I assembled this minimal Python script:

import requests
import json

http = requests.Session()

reconciliation_endpoint = 'https://wikidata.reconci.link/en/api'

query_string = '''{
    "queries": [
      {
        "query": "Christel Hanewinckel",
        "type": "Q5",
        "limit": 5,
        "type_strict": "should"
      }
    ]
}'''

response = http.post(reconciliation_endpoint, data=json.loads(query_string))
print(json.dumps(response.json(), indent=2))

I had been unable to get anything but a 404 from the API when I tried making the call using Postman. Using this script I did get an error message from the server:

{
  "arguments": {
    "lang": "en",
    "queries": "query"
  },
  "details": "Expecting value: line 1 column 1 (char 0)",
  "message": "invalid query",
  "status": "error"
}

This script and query is so incredibly simple and stripped down, I cannot see what the problem is. The actual construction of the query in your code is spread around enough that I can't really compare my query_string with one your code generates. But based on the error message, the problem doesn't seem to be a malformed query. Rather, the API seems to not be seeing the query at all. I didn't see anything in the documentation or your code about any particular required Content-Type headers or authorization being required. So I am mystified as to why it doesn't work.

I don't know how closely you monitor this issue tracker, but if you have any advice on what I'm doing wrong, I would greatly appreciate it. Thanks!

Steve Baskauf
Vanderbilt University Libraries
Nashville, Tennessee, USA

@baskaufs
Copy link
Author

I ended up getting an answer to my question from the OpenRefine forum: https://forum.openrefine.org/t/accessing-reconciliation-api-via/471

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

1 participant