I’m currently modifying code which uses the Microsoft.OData.Client. When calling SaveChangesAsync()
I get back the following error message:
Microsoft.OData.Client.DataServiceClientException: {
"error":{
"code":"","message":"An error has occurred.","innererror":{
"message":"No resources were found when selecting for update.","type":"Microsoft.Dynamics.Platform.Integration.Services.OData.ODataArgumentException"
The code to add and remove these object from Dynamics works without any errors. I can query for the object and no null will be returned, it exists, every property seems right when I compare the result I get back in Postman.
I then tried querying for the object, which obviously succeeds before modifying the property and saving it. Unfortunately that also returns the error message above. I tried modifying other properties and updating those, but the same thing happens. Does anyone have any clues what’s happening here?
public class Client: DataServiceContext
{
public virtual DataServiceQuery<ODataObjectToModify> SomeObjects { get; }
public Client(Uri serviceRoot) : base(serviceRoot)
{
this.SomeObjects = base.CreateQuery<ODataObjectToModify>("SomeObject");
}
public virtual void SomeMethodToUpdateAnObject(ODataObjectToModify objectToModify)
{
objectToModify.SomeCode = "GDD";
base.UpdateObject(objectToModify);
}
}
—
[Key("SomeKey")]
public class ODataObjectToModify
{
[IgnoreClientProperty]
public long Identifier { get; init; }
[IgnoreClientProperty]
public string SomeNumber { get; init; } = string.Empty;
public required string SomeCode { get; set; }
}