Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Odata - PATCH request to modify already existing Sales Order

Posted on by 30

I am on NAV 2018. Able to create Sales Order through the OData rest services. I need to modify the sales order in order change the "Tax_Area_Code" as the OData POST sales order doesn't work with "Tax_Area_Code". I am having difficulty understanding/using the etag returned by NAV.

Here is the etag returned when I create a sales order:

"@odata.etag": "W/\"JzUyO0pBQUFBQUNMQVFBQUFBSjcvMU1BVHdBdEFESUFNQUEzQURFQU1RQTRBRGNBQUFBQUFBPT05Ozc5NzM1NDIwNDA7Jw==\"",

Here is a reference on how to use the etag value in PATCH request: (https://community.dynamics.com/nav/f/microsoft-dynamics-nav-forum/232296/odata---cannot-update-data-on-page--/674638) last reply.

Key is: If-Match

Value:  W/"'<your etag>'"

in my case: W/"'JzUyO0pBQUFBQUNMQVFBQUFBSjcvMU1BVHdBdEFESUFNQUEzQURFQU1RQTRBRGNBQUFBQUFBPT05Ozc5NzM1NDIwNDA7Jw==\'"

error:

{
"error": {
"code": "BadRequest_MethodNotAllowed",
"message": "'PATCH' requests for 'webService' of EdmType 'Collection' are not allowed within Microsoft Dynamics NAV OData web services."
}
}

What am I doing wrong? Please comment if I am using the etag value properly.

Thanks!

  • Kishore22 Profile Picture
    Kishore22 30 on at
    RE: Odata - PATCH request to modify already existing Sales Order

    this issue has been resolved thanks!

  • RE: Odata - PATCH request to modify already existing Sales Order

    Check this ticket for solution

    I have face the same issue and found solution

    community.dynamics.com/.../patch-requests-for-of-edmtype-collection-are-not-allowed-within-dynamics-365-business-central-odata-web-services

    Enjoy !!!

  • Verified answer
    RE: Odata - PATCH request to modify already existing Sales Order

    I don't think that is the error you get if you use etag in a wrong way, but i think you should fetch an updated etag before modifying the order.

    etag is a sort of version of the record in the NAV/DBC table, and the idea behind it is to prevent someone changing the record while you are changing it. So you read the record and etag, modifies the data and asks NAV/DBC to update the record with your changes if the etag is unchanged. If etag is changed the error is sort of "someone else have changed the record, please do your changes again".

    Anyway - please have a look at the blog post also mentioned in the link you provide (scblog.lynge.org/). Althoug it is in Danish (sorry about that - I'm one of the authors :-) ) It implements this in PowerShell and shows examples on how to insert, modify and delete a customer. So you can see exactly how it is done and test it yourself.

    If you are familiar with powershell you should even be able to implement the change to want using the code - just for testing. And then you can look at requests/headers/body afterwards and implement the same in the language of your choice.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans