Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Updating a Sales Order Line using OData web services

(0) ShareShare
ReportReport
Posted on by 25

Hi,

I would like to update individual sales order lines by using the OData web services. I can successfully retrieve said sales order lines from the following url:

(path-to-odata-web-service)/SalesOrder/(Document_Type='Order',No='some-sales-order-id')/SalesOrderSalesLines

but when I try to issue a PUT request to this url I get the following error:

"'PUT' requests for 'SalesOrderSalesLines' of EdmType 'Collection' are not allowed within Microsoft Dynamics NAV OData web services."

I've already included the correct "If-Match" ETag header in the request.

Any ideas?

Regards,

Daníel

*This post is locked for comments

  • RE: Updating a Sales Order Line using OData web services

    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 !!!

  • RE: Updating a Sales Order Line using OData web services

    Hi,

    (I had written another reply previously, but that was targeted towards another post I had created earlier this week, and was thus irrelevant)

    Yes I managed to get this working.

    As stated above, then in order to be able to issue a PUT request, I had to include all primary keys for the given table I was saving data to. I.e.: the values for the primary key columns had to be present BOTH in the request body, AND in the URL.

    Also, one must take care of formatting the ETag correctly. It probably helps to learn about strong vs. weak ETags, i.e. sometimes the ETag is wrapped in an "envelope", which is basically the following: W/"actual-e-tag", sometimes there are single quotes there as well.

    Hope this helps,

    Daníel

  • LuisRodrigues Profile Picture
    LuisRodrigues 5 on at
    RE: Updating a Sales Order Line using OData web services

    Hi Daniel,

    I'm experiencing the same issue when trying to PUT Dimensions against an existing Sales Line that I've previously created.

    Did you get any further with this problem or a potential solution?

    Thanks,

    Luis

  • RE: Updating a Sales Order Line using OData web services

    The problem I had was that I wasn't referring to a single entity in the URL, i.e. I had to append the following to the url:

    (Document_Type='Order',Document_No='SP123456', Line_No=10000)

    By reading the $metadata document, we could determine which of the properties in the Sales Order Lines objects combined are the key to the object, and these must be in the URL.

    At least this allows me to issue a PUT/PATCH request to the url. However, I'm receiving another error now: 

    Another user has already changed the record

    which is not the case, I'm the only user. I'm passing the ETag in the If-Match header, and I'm fetching the order line records just moments before I issue the request so I've definitely got the latest ETag value. Still trying to figure out what is causing this error.

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
  • RE: Updating a Sales Order Line using OData web services

    Update: I've also tried issuing a PATCH request to the same url, this gives me a slightly different error:

    "'PATCH' requests for 'SalesOrderSalesLines' of EdmType 'Collection' are not allowed within Microsoft Dynamics NAV OData web services."

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans