0

I am creating an entity record by sending a REST call using XrmSvcToolkit.createRecord() method, but the JSON returned is accompanied with this error

EntityState must be set to null, Created (for Create message) or Changed (for Update message)

It's a simple REST call but I don't have any idea about this error. I googled it and found few hits but the problem still exists.

Guido Preite
  • 14,905
  • 4
  • 36
  • 65
naveed ali
  • 21
  • 3

2 Answers2

1

I had been getting the same error as you. In my scenario I had a pluggin that was triggered on creation of my record and it was in Post Operation. So afeter some search I found out that I had to change the EntityStatus of my context entity. I did that as follow and it worked pretty good!

EntityContext.EntityState = EntityState.Changed;

I hope it helps you!

Bruno Willian
  • 160
  • 2
  • 5
  • 18
0

If you are creating it, it looks like the EntityState needs to be set to Created.

Edit

Looks like this is an error when using the LINQ To CRM (see this post). My guess is that you have a plugin that is being triggered on your rest create, that is causing the exception that you are seeing.

Community
  • 1
  • 1
Daryl
  • 18,592
  • 9
  • 78
  • 145