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 :
Customer experience | Sales, Customer Insights,...
Answered

How to change the ownerid on an account

(0) ShareShare
ReportReport
Posted on by 10

Hi,

I am able to create a new account using the web API /api/data/v9.2/accounts. But when I do this. It allocates the account to the API account. How would I then change the _ownerid to the correct user after creation, if the _ownerid is a read-only property?

The goal is to export all accounts from another system to Dynamics  using the web API and then allocate these accounts to the correct users that also exist on the old system

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use following ownerid property setting:

    entity["ownerid@odata.bind"] = "/systemusers(956B410F-0F6E-E711-810E-00155D6FD705)";

  • BrianM2 Profile Picture
    10 on at

    Thanks for replying.

    I'm however not sure how the JSON string should look

    I have tried:

    POST /api/data/v9.2/accounts(6a09a29c-78c3-eb11-bacc-00224881adac)/ownerid

    {

         "ownerid@odata.bind":"/systemuser(151F639c-1c73-eb11-b1ab-000d3a253b40)"

    }

    Response

    A property 'ownerid' which only has property annotations in the payload but no property value is declared to be of type 'Edm.Guid'. In OData, only navigation properties and named streams can be represented as properties without values

    POST /api/data/v9.2/accounts(6a09a29c-78c3-eb11-bacc-00224881adac)/ownerid

    {

        "value": "ownerid@odata.bind"="/systemuser(151F639c-1c73-eb11-b1ab-000d3a253b40)"

    }

    Response

    an error occurred while validating input parameters

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Drop 'ownerid' piece from your post part like:

    POST /api/data/v9.2/accounts(6a09a29c-78c3-eb11-bacc-00224881adac)

  • BrianM2 Profile Picture
    10 on at

    Hi Andrew,

    I now get "Unmapped Request found, PathTemplate:~/entityset/key, HttpVerb:POST"

    Do you have an example of what the JSON should look like?

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Brian,

    It would be easier to do the opposite way. Post what you have, I will correct it.

  • BrianM2 Profile Picture
    10 on at

    Hi Andrew,

    Below is a sample in VB.NET. I have commented out some of my other attempts.

    Private Sub btnUpdateAccount_Click(sender As Object, e As EventArgs) Handles btnUpdateAccount.Click

           Dim m_http As New MSXML2.ServerXMLHTTP60

           Dim Responce As String = ""

           Dim _json As New JSON

           Dim tt() As JSON.AccountInfo

           Dim JSON As String = ""

           Try

               'JSON = "{""value"": ""123456789""}"

               'JSON = "{""value"":""/systemuser(151F639c-1c73-eb11-b1ab-000d3a253b40)""}"

               JSON = "{entity[""ownerid@odata.bind""]=""/systemuser(151F639c-1c73-eb11-b1ab-000d3a253b40)""}"

               'JSON = "{""ownerid@odata.bind"":""71872ae2-4eae-eb11-8236-00224881db1e""}"

              ' m_http.open("PUT", "/api/data/v9.2/accounts(6a09a29c-78c3-eb11-bacc-00224881adac)/accountnumber", False)

               m_http.open("POST", "/api/data/v9.2/accounts(6a09a29c-78c3-eb11-bacc-00224881adac)", False)

               m_http.setRequestHeader("Content-Type", "application/json")

               m_http.setRequestHeader("Authorization", "Bearer " & pub_Token)

               m_http.send(JSON)

               Responce = m_http.responseText()

           Catch ex As Exception

           End Try

       End Sub

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Not familiar with VB so it's hard for me to give you exact the code. Here is what you have to send:

    {

    "ownerid@odata.bind": "/systemuser(151F639c-1c73-eb11-b1ab-000d3a253b40)"

    }

    Also, you will have to use "PATCH" instead of "POST".  Check this - docs.microsoft.com/.../update-delete-entities-using-web-api

  • BrianM2 Profile Picture
    10 on at

    Hi Andrew,

    Thanks for your help. I got it to work. I had to also change /systemuser to /systemusers.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    If my reply (or replies) answers your question take a minute and verify the answer. You can do it by clicking "Yes" at the top of the reply (or replies) under the label "Does this answer your question?"

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans