Warm tip: This article is reproduced from serverfault.com, please click

Create inactive account

发布于 2020-12-14 18:07:09

I want to synchronize with another system, accounts, and if the entity is inactive in that system, I want to create the account with inactive status. something very simple like:

{       
    "accountnumber": "InactiveAcct",
    "name": "Account that should be created as inactive",
    "description": "demo",
    
    "statecode": 1,
    "statuscode": 2
}

I'm doing a POST request but as a reply I get:

{
    "error": {
        "code": "0x80048408",
        "message": "2 is not a valid status code for state code AccountState.Active on account with Id e2d0f844-313e-eb11-a813-000d3a795762."
    }
}
Questioner
mesteves
Viewed
0
Arun Vinoth 2020-12-15 02:31:03

Unfortunately you cannot create (POST) an inactive record, you have to create it first and then make an update (PATCH) call to mark inactive. This is by design and it’s a limitation. Read more

statecode field is not available for create. Record will be always created as active. The only way for you is to do 2 steps operation - create and set as inactive after.

In other words, statecode=0 is set as default by system, when you pass statuscode=2 in create payload - the platform validation kicks in and say this is invalid pair.