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 30

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.

  • Kishore22 Profile Picture
    Kishore22 30 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

    Got it! Thanks again

    I Gusti Made Ari Permadi

  • I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

    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')

  • Suggested answer
    Kishore22 Profile Picture
    Kishore22 30 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

    "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.

  • Verified answer
    I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

    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

  • Kishore22 Profile Picture
    Kishore22 30 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

    "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
    I Gusti Made Ari 3,594 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

    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')

  • Suresh Kulla Profile Picture
    Suresh Kulla 44,773 on at
    RE: Odata REST Web Services - Not able to Delete Sales Order

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

    www.kauffmann.nl/.../

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,575 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans