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 173
 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.
 
I have the same question (1)
  • Suggested answer
    YUN ZHU Profile Picture
    100,974 Super User 2026 Season 1 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,225 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,086 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,290 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,218

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans