Hello everyone,
I’m automating a two‑step file import into Cognos Analytics from a Windows SMB share, using the REST API and API‑key authentication. My Python notebook successfully:
-
Reads a CSV over SMB
-
Opens a Cognos session
… but fails with a 404 Not Found when calling the import endpoint:
import fsspec, requests, mimetypes, os
# 1. Read file from Windows SMB
fs = fsspec.filesystem(
"smb",
host="windowsServer.local",
username="username",
password="password"
)
remote_path = "/ca_jupyter/myfile.csv"
with fs.open(remote_path, "rb") as f:
file_bytes = f.read()
print("Read bytes:", len(file_bytes))
# 2. Determine MIME type
mime_type, _ = mimetypes.guess_type(remote_path)
mime_type = mime_type or "application/octet-stream"
# 3. Authenticate to Cognos via API‑Key
cognos_host = "http://db.local:9300" # my Cognos server URL
base_url = f"{cognos_host}/api/v1"
session = requests.Session()
auth_payload = {
"parameters": [
{"name": "CAMNamespace", "value": "LDAP"},
{"name": "CAMAPILoginKey", "value": "mycurrentAPIKey"}
]
}
resp = session.put(f"{base_url}/session", json=auth_payload, verify=False)
resp.raise_for_status()
session_key = resp.json()["session_key"]
headers = {
"IBM-BA-Authorization": session_key,
"Accept": "application/json"
}
# 4. Create import task → FAILS HERE with 404
import_req = {
"destination": "OBJECT_STORE_ID",
"filename": os.path.basename(remote_path)
}
resp = session.post(
f"{base_url}/files/import",
headers={**headers, "Content-Type": "application/json"},
json=import_req,
verify=False
)
resp.raise_for_status() # ← HTTPError: 404 Client Error: Not Found for url: http://db.local:9300/api/v1/files/import
Important note: I have verified that the API key, Cognos server URL, namespace, username, and password (where applicable) are all 100% correct—so this is not an authentication issue.
Questions:
-
Is the /api/v1/files/import
path still correct in Cognos Analytics 12.x, or has it moved/changed?
-
Beyond destination
and filename
, are there any additional required fields, headers, or query parameters?
-
Has anyone successfully used this endpoint in Python (API‑key auth)? A minimal example or pointers to updated docs would be hugely appreciated.
Thank you in advance for your insights!
— Sergej Bogdanov