Skip to main content

Notifications

Announcements

No record found.

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

Odata REST Web Services - Not able to Delete Sales Order

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 43,745 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

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans