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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Microsoft Dataverse de...
Power Apps
Answered

Microsoft Dataverse deactivate account entitiy using batching Web API

(0) ShareShare
ReportReport
Posted on by 13

Hi,

 

I there any way to deactivate entity using Microsoft Dataverse Web API Batching. For example it can be account entity. By deactivating I mean setting account statecode to 1 Inactive and statuscode 2 Inactive. I'm sending such kind of JSON structure 

{
"statecode": 1,
"statuscode": 2,
"accountnumber": "5",
"emailaddress1": "test.five@email.com",
"name": "Test Five for Test 2"
}

 

And getting response with bad request.

Response status code does not indicate success: 400 (Bad Request).

 

Thank you for answer in advance 🙂

I have the same question (0)
  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @lsta , 

    By WebAPI batch request do do mean an update, like this:
    PATCH: /api/data/v9.2/orb_testentities(<id_here>),

    having in the payload the JSON you posted above?
    In that case it should work.
    In case it still doesn't work, you can try first, if it's working with a JSON containing only statecode and statuscode?

    Maybe there is some server side code (like PlugIn, Sync PlugIn) registered on Update, which could cause problems. Maybe you can see something if you inspect the "System Jobs".

     

    Kind regards,

    Diana

  • lstanczak Profile Picture
    13 on at

    Hi @DianaBirkelbach

    Thank you for your answer. Yes exactly this is for me WebAPI Batch request. My url "/api/data/v9.1/accounts" is with version 9.1. Maybe there is some difference between versions. I'm making this request by adapter. I assuming that id is necessary to identify entity. Can I create account that is already inactive?

  • Verified answer
    lstanczak Profile Picture
    13 on at

    Hi @DianaBirkelbach 

    I found answer. The "accountid" was missing in JSON data. Now is working on. Do you know I can create account which is already inactive?

     

    Kind regards,

    Łukasz

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    HI Łukasz,


    If you have the ID in the url, you don't need the id in the payload:
     

    /api/data/v9.2/accounts(fa7d26ee-96b3-ea11-a812-000d3a21188e) 

    DianaBirkelbach_0-1616160404341.png

     

     

    Nope! Create disabled doesn't work! I tried a create with this:

     

    {statecode:1, statuscode:2, name:"dummy disabled"}

     

    and I get the error:

     

    "2 is not a valid status code for state code AccountState.Active on account with Id <id here>"

     

     

    Hope this helps!

    Kind regards,

    Diana

  • lstanczak Profile Picture
    13 on at

    Ok I see. Thank you for checking. Wish you good day 🙂

     

    Kind regards,

    Łukasz

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Diana, 

     

    Is there a solution for the "2 is not a valid status code for state code" error/ being able to create an inactive record rather than PATCH an existing active record?

    From my testing this error is prompted regardless of what fields are provided within the POST payload, following your comment about only containing statecode and statuscode. 

     

    Any clarification you may have on the reason for this API behaviour would be appreciated.

     

    Thanks,

    Luis

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 Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 93 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
Valantis Profile Picture

Valantis 49

Last 30 days Overall leaderboard