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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

oData batch context.SaveChanges(SaveChangesOptions.BatchWithSingleChangeset) issue

(0) ShareShare
ReportReport
Posted on by 2,676

I am getting following error when inserting record using oData call 

context.SaveChanges(SaveChangesOptions.PostOnlySetProperties | SaveChangesOptions.BatchWithSingleChangeset)

I am wondering if its Content-Type= Content-Type: multipart/mixed issue but i am not sure where i should set this parameter 

The context URL 'https://<url>/data/$metadata#ABCCustomeEntity/$entity' is invalid.

" at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.TryRead()\r\n at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.TryStartReadFeedOrEntry()\r\n at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.TryReadFeedOrEntry(Boolean lazy, ODataResourceSet& feed, MaterializerEntry& entry)\r\n at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.Read()\r\n at Microsoft.OData.Client.Materialization.ODataReaderEntityMaterializer.ReadNextFeedOrEntry()\r\n at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.ReadImplementation()\r\n at Microsoft.OData.Client.MaterializeAtom.MoveNextInternal()\r\n at Microsoft.OData.Client.MaterializeAtom.MoveNext()\r\n at Microsoft.OData.Client.BaseSaveResult.MaterializeResponse(EntityDescriptor entityDescriptor, ResponseInfo responseInfo, String etag)\r\n at Microsoft.OData.Client.BaseSaveResult.HandleResponsePost(EntityDescriptor entityDescriptor, String etag)\r\n at Microsoft.OData.Client.BaseSaveResult.HandleResponsePost(Descriptor descriptor, HeaderCollection contentHeaders)\r\n at Microsoft.OData.Client.BaseSaveResult.HandleOperationResponse(Descriptor descriptor, HeaderCollection contentHeaders)\r\n at Microsoft.OData.Client.BatchSaveResult.<HandleBatchResponse>d__29.MoveNext()"

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Muhammad Afsar Khan,

    Could you please share your code that you are that you are using for inserting records using OData call?

  • Muhammad Afsar Khan Profile Picture
    2,676 on at

    i simply used Sample oData app from Github.

    github.com/.../ODataChangesetsExample.cs

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Which version are you on? Are you trying to insert records into the same entities - SalesOrderHeader and SalesOrderLine?

  • Muhammad Afsar Khan Profile Picture
    2,676 on at

    I am using v10.0.15 and created one custom entity with no special code. Please don't ask if its my entity fault. if you know the reason of this error please suggest.

  • Suggested answer
    Muhammad Afsar Khan Profile Picture
    2,676 on at

    I am able to resolve this issue by removing unused entity load from ODataClient.ttinclude.  For instance, I changed the following foreach statement:

    foreach (IEdmEntitySet entitySet in container.EntitySets())

    {

       IEdmEntityType entitySetElementType = entitySet.EntityType();

       string entitySetElementTypeName = GetElementTypeName(entitySetElementType, container);

       string camelCaseEntitySetName = entitySet.Name;

       if (this.context.EnableNamingAlias)

       {

           camelCaseEntitySetName = Customization.CustomizeNaming(camelCaseEntitySetName);

       }

    }

    to

    foreach (IEdmEntitySet entitySet in container.EntitySets())

    {

       IEdmEntityType entitySetElementType = entitySet.EntityType();

       string entitySetElementTypeName = GetElementTypeName(entitySetElementType, container);

       string camelCaseEntitySetName = entitySet.Name;

       //start of manual fix

       //only process entity names that containin a specific string, to reduce the string size

       if (((camelCaseEntitySetName.Contains("LEDGER")) || (camelCaseEntitySetName.Contains("CUST"))) || (camelCaseEntitySetName.Contains("<MY_Custom entity prefix>")))

       {

         // emd of manual fix

         if (this.context.EnableNamingAlias)

         {

             camelCaseEntitySetName = Customization.CustomizeNaming(camelCaseEntitySetName);

         }

       }

    }

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 671

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 621 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 589 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans