I’ll provide a complete solution for configuring API role-permission mapping, troubleshooting custom role access, and ensuring proper automation integration.
API Role-Permission Mapping:
The core issue is that Agile’s REST API maintains a separate authorization layer from the standard privilege system. Custom roles must be explicitly configured for API access in multiple locations:
-
Enable API Access for Custom Role:
- Navigate to Admin > Roles & Privileges > CustomPartEditor
- In the Role Properties tab, enable “REST API Access”
- Set API Access Level to “Full” (or “Read-Only” if appropriate)
- Save the role configuration
-
Configure API Role Mapping:
Edit the rest-api-config.xml file (located in <AGILE_HOME>/config/):
<api-role-mappings>
<role-mapping>
<agile-role>CustomPartEditor</agile-role>
<api-privileges>
<privilege>part.create</privilege>
<privilege>part.read</privilege>
<privilege>part.update</privilege>
<privilege>bom.manage</privilege>
</api-privileges>
</role-mapping>
</api-role-mappings>
This mapping tells the REST API which operations to allow for your custom role. The privileges should match the functional capabilities your role needs.
- Update API Authentication Provider:
Modify the authentication provider configuration to recognize your custom role:
<authentication-provider>
<recognized-roles>
<role>CustomPartEditor</role>
</recognized-roles>
</authentication-provider>
Without this, the API authentication layer won’t process your custom role even if it exists in Agile.
Custom Role Troubleshooting:
Systematically verify each layer of API access:
-
Test Role Privileges: Log into Web Client as a user with CustomPartEditor role. Verify all part management operations work correctly. This confirms the underlying Agile privileges are properly configured.
-
Enable API Debug Logging: Add to agile.properties:
log4j.logger.com.agile.api.rest=DEBUG
log4j.logger.com.agile.security.api=DEBUG
- Test API Access Directly: Use curl or Postman to test API authentication:
curl -X GET "https://agile-server/Agile/RESTService/api/v1/parts" \
-H "Authorization: Bearer {token}" \
-H "X-Agile-Role: CustomPartEditor"
The X-Agile-Role header explicitly specifies which role to use for the API request. This is critical when users have multiple roles assigned.
- Review API Error Logs: After a failed API call, check the REST API logs (rest-api.log) for detailed error information:
- “Role not found” = Role mapping issue in rest-api-config.xml
- “Insufficient privileges” = API privilege mapping is incomplete
- “Authentication failed” = Role not recognized by authentication provider
Automation Integration:
For your automation workflows to work properly with custom roles:
- Configure Automation Client Authentication:
Your automation scripts must authenticate with role specification:
import requests
headers = {
"Authorization": f"Bearer {access_token}",
"X-Agile-Role": "CustomPartEditor",
"Content-Type": "application/json"
}
response = requests.get(
"https://agile-server/Agile/RESTService/api/v1/parts",
headers=headers
)
The X-Agile-Role header ensures the API uses your custom role’s permissions instead of defaulting to a different role the user might have.
- Implement Role-Based API Client:
Create a reusable API client class that handles role-specific authentication:
class AgileAPIClient:
def __init__(self, base_url, token, role):
self.base_url = base_url
self.headers = {
"Authorization": f"Bearer {token}",
"X-Agile-Role": role
}
- Handle Multi-Role Scenarios:
If your automation users have multiple roles, implement role selection logic:
def get_optimal_role(user_roles, required_operation):
# Map operations to roles with necessary privileges
if required_operation == "create_part":
return "CustomPartEditor"
elif required_operation == "approve_change":
return "ChangeApprover"
Complete Implementation Checklist:
- ✓ Enable “REST API Access” in custom role configuration
- ✓ Add role mapping to rest-api-config.xml with all required API privileges
- ✓ Update authentication provider to recognize custom role
- ✓ Restart Agile application server to load configuration changes
- ✓ Enable API debug logging for troubleshooting
- ✓ Test API access using curl/Postman with explicit role header
- ✓ Update automation scripts to include X-Agile-Role header
- ✓ Verify all API endpoints needed by automation are accessible
Validation Testing:
Test your configuration with these scenarios:
-
Single Role User: User with only CustomPartEditor role accesses API
- Should succeed without X-Agile-Role header
-
Multi-Role User: User with CustomPartEditor + other roles accesses API
- Should succeed when X-Agile-Role: CustomPartEditor is specified
- Should fail or use different permissions without role header
-
Automation Client: Automated script creates part via API
- Should succeed with proper authentication and role specification
- Should handle 403 errors gracefully with retry logic
-
Privilege Boundary: Test operations outside role privileges
- Should fail with 403 for operations not in API privilege mapping
- Error message should clearly indicate insufficient privileges
Common Pitfalls to Avoid:
-
Configuration Caching: After modifying rest-api-config.xml, you MUST restart the Agile server. Configuration changes aren’t hot-reloaded.
-
Role Name Case Sensitivity: Role names in API headers and configuration are case-sensitive. “CustomPartEditor” ≠ “customparteditor”.
-
Incomplete Privilege Mapping: Map ALL required API privileges, not just the obvious ones. Missing even one privilege can cause cryptic 403 errors.
-
Token vs Role Confusion: The authentication token identifies the USER, but the X-Agile-Role header specifies which of that user’s roles to use for authorization.
Performance Considerations:
For high-volume automation:
- Implement connection pooling in your API client to reuse authenticated sessions
- Cache role-to-privilege mappings to avoid repeated configuration lookups
- Use batch API operations when possible to reduce request overhead
- Monitor API response times - custom role authorization adds 5-10ms per request
With this complete configuration, your custom roles will work seamlessly with the REST API, enabling full automation integration for part management workflows. The key is ensuring proper mapping at all three layers: Agile role configuration, REST API configuration, and authentication provider configuration.