API connection for Mutiple end users

I set up an API connection to for example a CC header table and it works great for me but when other users try to reload all data in Spotfire for example they all get an error

Data table ‘cc_header_table_datatable’ could not be reloaded

The data source ‘CC Header Data - DataTable’ could not be reloaded.

Could not execute function call ‘CC Header Data - DataTable’

any ideas why?? Thank you

Do you have token refresh logic in your Python code, and are you all using the same API keys?

We are all using the same API keys, so you think the issue is a refresh logic code?

I’m not sure why you are getting that error. Would you be able to provide more details about the API implementation? The errors you provided seem to be Spotfire errors and not errors with the API.

from datetime import datetime
import os
import json
import requests
import pandas as pd
import numpy as np
from combocurve_api_v1 import ServiceAccount , ComboCurveAuth, pagination

def auth_session():

fileName = "API Service Key2.json"
filePath = r"\\GRN-AZ-APPS-01\Petra"

if not os.path.exists(filePath):
    print("Network drive not accessible ")

service_file = os.path.join(filePath,fileName)

if not os.path.exists(service_file):
    print("Service API file not accessible ")

service_account = ServiceAccount.from_file(service_file)
api_key = "**####REMOVED BY ADMIN###**"
combo_curve_auth = ComboCurveAuth(service_account, api_key)
auth_headers = combo_curve_auth.get_auth_headers()

return auth_headers

auth_headers = auth_session()
projectId = ‘636a654f650fb80012bafc97’

url_endpoint = “https://api.combocurve.com/v1/projects/636a654f650fb80012bafc97/company-wells?take=1000
complete_df = pd.DataFrame()
get_next_page = True
page_num = 1
while get_next_page:

response = requests.get(url_endpoint, headers = auth_headers)

if response.status_code != 200:

	raise Exception (f"Error getting data table: {response.status_code}, {response.text}")

else:
	#print({response.status_code})#, {response.text})
	print("getting page: ", page_num)
	data = response.text
	url_endpoint = pagination.get_next_page_url(response.headers)
	page_num = page_num +1
	get_next_page = url_endpoint is not None

	data_dict = json.loads(data)
	
	
	df = pd.json_normalize(data_dict)
	complete_df = pd.concat([complete_df,df],ignore_index = True)

print (complete_df.shape)
cc_header_DF = complete_df.fillna(np.nan)#where(pd.notna(complete_df), None))

well_list = cc_header_DF[‘id’]

	#print (complete_df.shape)
	 
	# Create a dictionary of fill values based on data types

#fill_values = {col: 0 if complete_df[col].dtype.kind in ‘biufc’ else ‘’ for col in complete_df.columns}

	# Fill NaN values using the dictionary

#complete_df = complete_df.fillna(fill_values)

#cc_header_table = complete_df #.fillna(where(pd.notna(df), None)

Works on my machine but none others on our remote desktop server

I am not 100% sure what the issue is because the error messages in Spotfire are not very detailed, making it difficult to diagnose. I would add more detailed logging if possible to try to better understand what is causing the issue. That being said here are some things I would look into based on the script you provided.

  • The script references a network drive (filePath = r"\\GRN-AZ-APPS-01\Petra"). If other users don’t have access to this network drive, or if the drive is not correctly mapped for them, the script will fail.

  • The service account file (API Service Key2.json) and the API key must be accessible and valid. If another user cannot access the service account file or if their environment is missing the required API key, the script will fail.

  • The Python environment on the remote desktop server may differ from your local environment. This could include different versions of Python, missing libraries, or differences in how libraries are configured.

  • If Spotfire is calling this script as part of its data reload process, there might be differences in how it handles the script execution compared to running it locally.