Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
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.

Categories:
  • 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,590 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,590 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,590 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,638 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/.../

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,986 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans