Retrieve child project-item codes for a project in the API key’s business unit.
Request
GET https://api.myzahara.net/api/{businessUnitApiKey}/Project/GetProjectItemsCodes/{projectId}/false
Send Accept: application/json. No request body is required.
Put the parent ProjectId in the path. The /false segment selects the exclude-deleted variant. ProjectItemCodeId identifies a child item and is separate from ProjectId.
Authentication and scope
| Parameter | Location | Meaning |
|---|---|---|
| businessUnitApiKey | URL path | API key for the owning business unit; not a tenancy key, numeric ID or user name. |
| projectId | URL path | Integer ≥ 1; use the owning business unit’s record reference. |
Store the key in an environment variable or secret store. Because it appears in the URL path, redact request URLs in logs, proxies and monitoring. Do not put real keys in source examples, shared screenshots or coding-agent prompts. Response codes and names may also be confidential.
Working examples
Set the environment variables below, then run the example in your preferred language. Use a secure terminal for business data.
| Environment variable | Purpose |
|---|---|
| ZAHARA_BUSINESS_UNIT_API_KEY | Business-unit API key, kept private. |
| ZAHARA_PROJECT_ID | projectId. Use a valid integer in the documented context. |
cURL
Requires cURL 7.76.0+ for --fail-with-body. It prints the full result; use a secure development terminal.
# cURL 7.76.0+. Set the environment variables documented below.
# Treat response data as confidential. Keep keys out of logs.
set -e
curl --fail-with-body --silent --show-error --max-time 30 \
--request GET \
--header 'Accept: application/json' \
"https://api.myzahara.net/api/${ZAHARA_BUSINESS_UNIT_API_KEY:?Set ZAHARA_BUSINESS_UNIT_API_KEY}/Project/GetProjectItemsCodes/${ZAHARA_PROJECT_ID:?Set ZAHARA_PROJECT_ID}/false"
JavaScript (Node.js 22+)
Uses built-in fetch, a 30-second timeout and an HTTP status check. No extra packages are required.
// Node.js 22+. Standard library only.
function required(name) {
const value = process.env[name];
if (!value) throw new Error('Set ' + name);
return value;
}
const key = required('ZAHARA_BUSINESS_UNIT_API_KEY');
const base = 'https://api.myzahara.net';
let path = "Project/GetProjectItemsCodes/{projectId}/false";
const projectId = required('ZAHARA_PROJECT_ID');
if (!/^\d+$/.test(projectId) || !Number.isSafeInteger(Number(projectId)) || Number(projectId) < 1) throw new Error('Invalid ZAHARA_PROJECT_ID');
path = path.replace('{projectId}', encodeURIComponent(projectId));
const url = new URL(base + '/api/' + encodeURIComponent(key) + '/' + path);
let response;
try {
response = await fetch(url, {
method: 'GET', headers: { Accept: 'application/json' },
signal: AbortSignal.timeout(30000), redirect: 'error'
});
} catch { throw new Error('Zahara request failed or timed out; URL omitted to protect the key'); }
if (!response.ok) throw new Error('Zahara returned HTTP ' + response.status);
const text = await response.text();
// Some methods may return an empty successful body. Do not assume a JSON shape.
const result = text.trim() ? JSON.parse(text) : null;
// Use a secure console; response fields may include financial or business data.
console.log(JSON.stringify(result, null, 2));
Python 3 (standard library)
Rejects redirects and reports HTTP/network errors without exposing the credential-bearing URL.
# Python 3. Standard library only.
import json
import os
from urllib.parse import quote, urlencode
from urllib.request import Request, build_opener, HTTPRedirectHandler
from urllib.error import HTTPError, URLError
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
def required(name):
value = os.environ.get(name)
if not value:
raise SystemExit('Set ' + name)
return value
key = required('ZAHARA_BUSINESS_UNIT_API_KEY')
base = 'https://api.myzahara.net'
path = "Project/GetProjectItemsCodes/{projectId}/false"
projectId = required('ZAHARA_PROJECT_ID')
if not projectId.isascii() or not projectId.isdigit() or int(projectId) < 1:
raise SystemExit('Invalid ZAHARA_PROJECT_ID')
path = path.replace('{projectId}', quote(projectId, safe=''))
url = base + '/api/' + quote(key, safe='') + '/' + path
request = Request(url, method='GET',
headers={'Accept': 'application/json'})
try:
with build_opener(NoRedirect).open(request, timeout=30) as response:
text = response.read().decode('utf-8')
except HTTPError as error:
raise SystemExit('Zahara returned HTTP ' + str(error.code)) from None
except URLError:
raise SystemExit('Zahara request failed; URL omitted to protect the key') from None
result = json.loads(text) if text.strip() else None
# Use a secure console: the result may contain confidential data.
print(json.dumps(result, indent=2))
Successful response
The response is a JSON array of project items. Process each returned item, and handle an empty array without treating it as an HTTP failure.
Empty response example
[]
Project-item fields
| Field | Use |
|---|---|
| ProjectItemCodeId | Child-item reference. |
| ProjectId | Parent project reference. |
| Code / Description | Display code and description. |
| IsActive / Void | Availability flags. |
| DateCreated / LastUpdated | Record timestamps. |
| Id / Project | Additional identifier and project relationship. |
Handling failures
Handle HTTP errors separately from an empty result. An invalid key returns HTTP 401. Redact the credential-bearing URL in logs and error reports.
Check the HTTP status before reading the result. Handle timeouts and unexpected response formats separately from valid empty results or negative decisions. The samples make one request and do not automatically retry.
Integration notes
- Iterate over the returned array. An empty array contains no project items; it does not by itself establish that the parent project exists.
- Use ProjectItemCodeId when updating an item and ProjectId when requesting items for a parent.
- Inspect IsActive and Void before offering an item for selection.