# Update Project Item

Last updated: 2026-11-26

Update an existing project-item code using POST.

 

## Request

 

` POST https://api.myzahara.net/api/{businessUnitApiKey}/Project/UpdateProjectItemsCode/{projectItemCodeId} `

 

Send ` Accept: application/json ` and ` Content-Type: application/json `.

 

Use POST to Project/UpdateProjectItemsCode/{projectItemCodeId}. Put the same child identifier in the path and ProjectItemCodeId body field, and use the intended parent ProjectId.

 

### Request body example

 

Replace the fictional identifiers and values with those for your business.

 

```json
{
  "ProjectItemCodeId": 1002,
  "ProjectId": 1001,
  "Code": "ITEM-EXAMPLE",
  "Description": "Updated example project item",
  "LastUpdated": "2026-01-15T10:30:00Z",
  "IsActive": true,
  "DateCreated": "2026-01-01T00:00:00Z",
  "Void": false
}
```

 

### Request fields

 

| Field | Example type | Use |
| --- | --- | --- |
| ProjectItemCodeId | number | Numeric child-item reference; match the path identifier. |
| ProjectId | number | Numeric parent project reference. |
| Code | string | Business-facing display code. |
| Description | string | Description of the record. |
| LastUpdated | string | Record update timestamp in the request shape. |
| IsActive | boolean | Activity flag; set it explicitly. |
| DateCreated | string | Record creation date-time. |
| Void | boolean | Void flag; choose it deliberately. |

 

## 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. |
| projectItemCodeId | 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. Save the request body as a JSON file and set ZAHARA\_REQUEST\_FILE to its path. Set ZAHARA\_API\_BASE\_URL explicitly to the API origin you intend to use. Use a secure terminal for business data.

 

| Environment variable | Purpose |
| --- | --- |
| ZAHARA\_BUSINESS\_UNIT\_API\_KEY | Business-unit API key, kept private. |
| ZAHARA\_PROJECT\_ITEM\_CODE\_ID | projectItemCodeId. Use a valid integer in the documented context. |
| ZAHARA\_REQUEST\_FILE | File containing a JSON object. |
| ZAHARA\_API\_BASE\_URL | API origin for the selected environment, without an /api path. |

 

### cURL

 

Requires cURL 7.76.0+ for ` --fail-with-body `. It prints the full result; use a secure development terminal.

 

```sh
# cURL 7.76.0+. Set the environment variables documented below.
# Send the request to the intended environment and business unit.
set -e
curl --fail-with-body --silent --show-error --max-time 30 \
  --request POST \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-binary "@${ZAHARA_REQUEST_FILE:?Set ZAHARA_REQUEST_FILE}" \
  "${ZAHARA_API_BASE_URL:?Set ZAHARA_API_BASE_URL}/api/${ZAHARA_BUSINESS_UNIT_API_KEY:?Set ZAHARA_BUSINESS_UNIT_API_KEY}/Project/UpdateProjectItemsCode/${ZAHARA_PROJECT_ITEM_CODE_ID:?Set ZAHARA_PROJECT_ITEM_CODE_ID}"
```

 

### JavaScript (Node.js 22+)

 

Uses built-in fetch, a 30-second timeout and an HTTP status check. No extra packages are required.

 

```javascript
// Node.js 22+. Standard library only.
import { readFileSync } from 'node:fs';
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');
// Send the request to the intended environment and business unit.
const base = required('ZAHARA_API_BASE_URL').replace(/\/$/, '');
let path = "Project/UpdateProjectItemsCode/{projectItemCodeId}";
const projectItemCodeId = required('ZAHARA_PROJECT_ITEM_CODE_ID');
if (!/^\d+$/.test(projectItemCodeId) || !Number.isSafeInteger(Number(projectItemCodeId)) || Number(projectItemCodeId) < 1) throw new Error('Invalid ZAHARA_PROJECT_ITEM_CODE_ID');
path = path.replace('{projectItemCodeId}', encodeURIComponent(projectItemCodeId));
const url = new URL(base + '/api/' + encodeURIComponent(key) + '/' + path);

const payload = JSON.parse(readFileSync(required('ZAHARA_REQUEST_FILE'), 'utf8'));
let response;
try {
  response = await fetch(url, {
    method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify(payload),
    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
# 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')
# Send the request to the intended environment and business unit.
base = required('ZAHARA_API_BASE_URL').rstrip('/')
path = "Project/UpdateProjectItemsCode/{projectItemCodeId}"
projectItemCodeId = required('ZAHARA_PROJECT_ITEM_CODE_ID')
if not projectItemCodeId.isascii() or not projectItemCodeId.isdigit() or int(projectItemCodeId) < 1:
    raise SystemExit('Invalid ZAHARA_PROJECT_ITEM_CODE_ID')
path = path.replace('{projectItemCodeId}', quote(projectItemCodeId, safe=''))
url = base + '/api/' + quote(key, safe='') + '/' + path

with open(required('ZAHARA_REQUEST_FILE'), encoding='utf-8') as file:
    payload = json.load(file)
data = json.dumps(payload).encode('utf-8')
request = Request(url, data=data, method='POST',
    headers={'Accept': 'application/json', 'Content-Type': '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

 

Check the HTTP status before using the response. If the body contains JSON, parse it before accessing its values; handle an empty successful body separately.

 

After the request, retrieve the project item to confirm the intended values and obtain any identifiers needed by subsequent calls.

 

## Handling failures

 

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.

 

After an uncertain outcome, retrieve the relevant records before repeating a request that can change business data.

 

## Integration notes

 

- Use POST for this update endpoint.
- Keep the path and body identifiers consistent.
- Choose IsActive and Void deliberately; the example keeps the item active and non-void.
- Retrieve the current item before constructing the body, preserve the appropriate timestamps, and read the project’s items back afterwards.
