AUR5003

Error Message

AUR5003: Default headers must be a plain object.

Description

This error occurs when attempting to configure default headers with a value that is not a plain object. The HttpClient expects default headers to be provided as a simple key-value object where keys are header names and values are header values.

Common Scenarios

Passing Non-Object Values

// ❌ Wrong: Passing non-object values
client.configure(config => {
  return config.withDefaults({
    headers: 'Content-Type: application/json' // String instead of object
  });
});

Solution

// ✅ Correct: Use plain object for headers
client.configure(config => {
  return config.withDefaults({
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
  });
});

Last updated

Was this helpful?