ShoryQuery Syntax Question

This forum is for programmers who have questions about the source code.
Post Reply
baoluan1
Posts: 13
Joined: Wed Jan 19, 2022 8:37 am

ShoryQuery Syntax Question

Post by baoluan1 » Thu Jan 20, 2022 7:17 am

I am currently trying to utilize the ShortQuery feature of the API and having issues. My Get requests for other resources work fine so I know authentication isnt the issue. I have had the clinics update to 21.3.39 to ensure its not an outdated version that doesnt allow for ShortQuery usage. My python syntax is as follows:

Code: Select all

testsite = "https://api.opendental.com/api/v1/queries/ShortQuery?Offset=000"
test = requests.put(testsite, headers = header, data = {"SqlCommand": "SELECT * FROM payperiod"})
test.json()

my response is

'The server has encountered an error.'



Any insight into what I'm doing wrong would be much appreciated.

SLeon
Posts: 476
Joined: Mon Mar 01, 2021 10:00 am

Re: ShoryQuery Syntax Question

Post by SLeon » Thu Jan 20, 2022 1:13 pm

Your JSON formatting looks correct. You can always test against our demo database with our testing credentials to confirm (See https://www.opendental.com/site/apisetup.html).

That specific error message is most often seen when there is an issue with the dental office's eConnector. Usually this due to version of the eConnector being behind the version of the API method. However, Queries PUT ShortQuery was added in 21.2, which is later than the 21.3.39 you believe the dental office is on. Are you able to hit other 21.2 endpoints successfully, such as PatientNotes GET and PUT? They were added slightly later in 21.2 than Queries PUT ShortQuery and would confirm if this was a versioning issue.

User avatar
jordansparks
Site Admin
Posts: 5739
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: ShoryQuery Syntax Question

Post by jordansparks » Thu Jan 20, 2022 5:45 pm

We should improve this message to indicate that it's likely a version issue. We might even be able to get fancy about it and check the required version for each API method.
Jordan Sparks, DMD
http://www.opendental.com

baoluan1
Posts: 13
Joined: Wed Jan 19, 2022 8:37 am

Re: ShoryQuery Syntax Question

Post by baoluan1 » Fri Jan 21, 2022 9:18 am

Good morning

I tried utilizing the test keys with no luck there either. So it’s not a clinic software version issue.

Code: Select all

Dev_KEY =  "NFF6i0KrXrxDkZHt"
Customer_KEY = "VzkmZEaUWOjnQX2z"
header = {"Authorization" : "ODFHIR %s/%s" % (Dev_KEY,Customer_KEY)}

ShortQuerysite = "https://api.opendental.com/api/v1/queries/ShortQuery"
results = requests.put(ShortQuerysite, headers = header, data = {"SqlCommand": "SELECT * FROM clinic"})
results.json()

SLeon
Posts: 476
Joined: Mon Mar 01, 2021 10:00 am

Re: ShoryQuery Syntax Question

Post by SLeon » Fri Jan 21, 2022 11:55 am

This issue was determined to be Python-related and has been resolved. In this instance the label for the JSON string needed to be changed from 'data' to 'json', shown below.

Code: Select all

ShortQuerysite = "https://api.opendental.com/api/v1/queries/ShortQuery"
results = requests.put(ShortQuerysite, headers = header, json = {"SqlCommand": "SELECT * FROM clinic"})
results.json()

Post Reply