Azure / Azure/identity-management-samples

PAM Portal: Role activation fails with HTTP 406 due to missing contentType

Open
#12 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22
Forks
27
PR merge metrics
No merged PRs in 30d

Description

# Fix: Add missing contentType to createPamRequest AJAX call

## Problem
Role activation fails with HTTP 406 "Not Acceptable" errors in the PAM Portal sample due to missing `contentType` specification in the `createPamRequest()` function.

## Root Cause
Modern jQuery versions default to sending JSON data when no `contentType` is specified, but the PAM REST API only accepts `application/x-www-form-urlencoded` format.

## Solution
Add explicit `contentType` specification to the AJAX request in `pamRestApi.js`:

```javascript
// Before (broken)
return $.ajax({
url: BuildPamRestApiUrl('pamrequests'),
type: 'POST',
data: requestJson,
xhrFields: { withCredentials: true }
})

// After (fixed)
return $.ajax({
url: BuildPamRestApiUrl('pamrequests'),
type: 'POST',
data: requestJson,
contentType: 'application/x-www-form-urlencoded', // Add this line
xhrFields: { withCredentials: true }
})
```

## Files Changed
- `Privileged-Access-Management-Portal/src/js/pamRestApi.js` (line ~51 in `createPamRequest` function)

## Testing
**Before**: HTTP 406 errors when activating roles
**After**: Successful role activation with HTTP 200 and proper response

## Impact
- **Fixes**: Role activation functionality
- **Security**: Improves security (form-encoded vs JSON)
- **Compatibility**: No breaking changes, fully backward compatible

This is a minimal one-line fix that resolves a critical functionality issue in the sample.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.