Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to change the ownerid on an account

    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?"

  • BrianM2 Profile Picture
    10 on at
    RE: How to change the ownerid on an account

    Hi Andrew,

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

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to change the ownerid on an account

    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
    RE: How to change the ownerid on an account

    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

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to change the ownerid on an account

    Brian,

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

  • BrianM2 Profile Picture
    10 on at
    RE: How to change the ownerid on an account

    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?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to change the ownerid on an account

    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
    RE: How to change the ownerid on an account

    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
    RE: How to change the ownerid on an account

    Hello,

    Try to use following ownerid property setting:

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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 91

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 78 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans