web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Odata REST Web Services - Not able to Delete Sales Order

(0) ShareShare
ReportReport
Posted on by 51

Hi,

I am creating sales orders through the odata web services. Sometimes the sales lines are missing (other department needs to populate it) and I need to delete the sales order (the sales lines can be empty or have 1 or 2 lines) completely for the time being or else shipping would start working on incomplete SO. I'm using the http DELETE method with sales order number as the filter:

DELETE: URL - NAVSANDBOX.com:7048/.../SalesOrder eq 'SO-2078422'

But I get a 405 saying "'DELETE' requests for 'SalesOrder' of EdmType 'Collection' are not allowed within Microsoft Dynamics NAV OData web services."

Screenshot-from-2019_2D00_12_2D00_10-16_2D00_29_2D00_46.png

Please suggest me how his can be accomplished.

Thanks in advance,

Kishore.

I have the same question (0)
  • Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    You need to specify the ETag, please check the below link and search for ETag

    www.kauffmann.nl/.../

  • Verified answer
    I Gusti Made Ari Profile Picture
    3,600 on at

    For deletion you can  use below call to get one entity only as using $Filter can return collection :

    DELETE http://{{ipandport}}/{{servicename}}/ODataV4/Company('{{companyname}}')/SalesOrder('Order','SO-2708422')

  • Kishore22 Profile Picture
    51 on at

    "DELETE http://{{ipandport}}/{{servicename}}/ODataV4/Company('{{companyname}}')/SalesOrder('Order','SO-2708422')"

    this is not working.

    Error: {

       "error": {

           "code": "BadRequest_ResourceNotFound",

           "message": "Resource not found for the segment 'SalesOrder'."

       }

    }

    Says resource not available. But when I do GET - "SalesOrder?$filter=No eq 'SO-2078422'"

    I get the correct response.

  • Verified answer
    I Gusti Made Ari Profile Picture
    3,600 on at

    I think the SO number was typo, resource not found means the SO Number  does not exist . Try below :

    DELETE http://{{ipandport}}/{{servicename}}/ODataV4/Company('{{companyname}}')/SalesOrder('Order','SO-2078422')

    You will get response 204 " No Content" when it is successfully deleted

  • Suggested answer
    Kishore22 Profile Picture
    51 on at

    "DELETE http://{{ipandport}}/{{servicename}}/ODataV4/Company('{{companyname}}')/SalesOrder('Order','SO-2078422')"

    is working absolutely fine.

    I Gusti Made Ari Permadi  Thanks a lot!

    Will the same format `SalesOrder('Order','SO-2078422')` work for items/zip codes/customers?

    Like: Items('Item','1234'), Customers('Customer','56787')?

    Thanks again!,

    Kishore.

  • I Gusti Made Ari Profile Picture
    3,600 on at

    Yes, it should be working as well. You only need to supply the primary key value . For items primary key is only Number so should be like this Items('1234')

  • Kishore22 Profile Picture
    51 on at

    Got it! Thanks again

    I Gusti Made Ari Permadi

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=%2F.++6" - Nested quantifier +.