Issues making any requests

For requests or help with our API
Post Reply
captainblund
Posts: 4
Joined: Tue Oct 03, 2023 6:58 pm

Issues making any requests

Post by captainblund » Sun Jan 28, 2024 6:55 pm

Hi everyone,

So I've been trying to make a basic request to the local server to get demo patient 11 in the database. However, I seem to be having trouble with making basic contact with the API. I've attached my firewall settings as well as my python script (Ran this from wsl) in this post. Could anyone please tell me what I might be doing wrong? I also made sure to launch openDental itself as admin.

If I try to access the API using a simple method, such as through chrome, such as with

Code: Select all

http://localhost:30223/api/v1/patients/11/
It gives me a "not authorized" error, which makes me believe that requests can still somehow go through.

Code: Select all

import requests

# Replace these values with your actual data
api_base_url = "http://localhost:30223/api/v1"
endpoint = "/patients/11/"
developer_key = "NFF6i0KrXrxDkZHt"
customer_key = "VzkmZEaUWOjnQX2z" #Have tried this with my own keys

# Combine developer key and customer key for Authorization header
authorization_header = f"ODFHIR {developer_key}/{customer_key}"

# Define headers
headers = {
    "Content-Type": "application/json",
    "Authorization": authorization_header,
}

# Define the full URL for the API call
url = api_base_url + endpoint

# Make a GET request
response = requests.get(url, headers=headers)
# Check the response status code
if response.status_code == 200:
    # API call was successful, process the response
    data = response.json()
    print("API Response:", data)
else:
    # Print an error message if the API call was not successful
    print(f"Error: {response.status_code} - {response.text}")
Image

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

Re: Issues making any requests

Post by SLeon » Mon Jan 29, 2024 8:11 am

Good morning,

Are you trying to use the Local or the Service mode of the API? Your URL uses port 30223, which would indcate the API Service, but you also mention running Open Dental as admin, which is necessary only for the Local mode.

I would first recommend reading ang following the troubleshooting steps found in our API Guide - API Service forum post.

It is important to note the that both Local and Service modes connect to a database on a local network. For this reason, the Public Demo API credentials will never work for these modes (as its database lives at Open Dental HQ).

captainblund
Posts: 4
Joined: Tue Oct 03, 2023 6:58 pm

Re: Issues making any requests

Post by captainblund » Mon Feb 05, 2024 10:25 pm

Sorry if I'm reviving an old post, I realized my mistake. I inteded to use local mode and did not set the port correctly at 30222. Thank you so much Leon.

Post Reply