web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

An element with same key but a different value already exist

(3) ShareShare
ReportReport
Posted on by 179
 I am using power shell to integrate data verse table to business central. However when i execute the script i am facing this issue 
System.ArgumentException: An element with the same key but a different value already exists. Key: 'systemuser'
 
Please let me know how this issue can be resolved.
 
  • Suggested answer
    YUN ZHU Profile Picture
    103,089 Super User 2026 Season 2 on at
    Hi, I didn't encounter this problem when testing before. You can check the difference with your code.
     
     
    Thanks.
    ZHU
  • CU19091850-0 Profile Picture
    6 on at
    I have added new field in Customer Asset table, and trying to run the Powershell script. However, I am also getting similar error:
    Please suggest how o resolve this issue.
  • Suggested answer
    Rishabh Kanaskar Profile Picture
    6,231 Super User 2026 Season 1 on at
    This error is pretty common when working with PowerShell + Dataverse + Business Central APIs. It usually happens because of how you’re building your hashtable/dictionary for headers, query parameters, or JSON payload before calling the API.
     
    1. The error:
    > System.ArgumentException: An element with the same key but a different value already exists. Key: 'systemuser'
    means that somewhere in your code you are adding the same key twice to a collection that enforces uniqueness, such as:
    > A PowerShell Hashtable (@{})
    > A Dictionary object in .NET
    > Or a header collection in Invoke-RestMethod or Invoke-WebRequest
    If you accidentally do something like this:
     
    $headers = @{
        "Authorization" = "Bearer $token"
        "Content-Type"  = "application/json"
        "systemuser"    = "value1"
        "systemuser"    = "value2"  # <-- same key, different value
    }

    > PowerShell will throw the exact error you’re seeing.
     
    2. Fix in PowerShell
     
    If you are using a Hashtable, you can check for existing keys before adding:
    if (-not $headers.ContainsKey("systemuser")) {
        $headers["systemuser"] = "yourvalue"
    } else {
        # Optionally overwrite instead of adding again
        $headers["systemuser"] = "yourvalue"
    }

    > Or simply remove the duplicate definition.
     
    Thanks
    Rishabh
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 711 Super User 2026 Season 2

#2
Teagen Boll Profile Picture

Teagen Boll 377 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 367 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans