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 :
Supply chain | Supply Chain Management, Commerce
Unanswered

OData/WebAPI DELETE for Product Category is returning 204 but the entity is not actually being deleting

(0) ShareShare
ReportReport
Posted on by 15

I'm going crazy and can't figure this out. 

In Postman, I'm calling 

  • GET {{d365BaseUrl}}/data/ProductCategories(ProductCategoryHierarchyName='Physical Inventory',CategoryName='test4') -- This works just fine and returns the prodcut category
  • DELETE {{d365BaseUrl}}/data/ProductCategories(ProductCategoryHierarchyName='Physical Inventory',CategoryName='test4') -- Returns a 204 and I assume it's deleted
  • NOPE It's still there!  I've tried passing an empty body {} as I saw in a related post for CRM, but that didn't help at all.  This is D365 F&O / Supply Chain Management.

Deleting items with Postman works just fine for ProductsV2, but not for Product Categories.  I'm baffled.  

Any help would be greatly appreciated.

Thanks,
Tom

I have the same question (0)
  • tomhundley Profile Picture
    15 on at

    Update: Not that I really expected anything different, but using the Odata client in c# performs the exact same way.  I call delete and the data is still there:

        class Program
        {
            public static string ODataEntityPath = ClientConfiguration.Default.ActiveDirectoryResource   "/data";
            static void Main(string[] args)
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                Uri oDataUri = new Uri(ODataEntityPath, UriKind.Absolute);
                var context = new Resources(oDataUri);
    
                context.SendingRequest2  = new EventHandler(delegate (object sender, SendingRequest2EventArgs e)
                    {
                        var authenticationHeader = OAuthHelper.GetAuthenticationHeader(useWebAppAuthentication: true);
                        e.RequestMessage.SetHeader(OAuthHelper.OAuthHeader, authenticationHeader);
                    });
    
    
                var category = context.ProductCategories.AsEnumerable().SingleOrDefault(p => p.ProductCategoryHierarchyName == "Physical Inventory" && p.CategoryName == "test4");
                if (category == null)
                {
                    Console.WriteLine("can't find category");
                    Console.ReadLine();
                    return;
    
                }
    
                context.DeleteObject(category);
                context.SaveChanges();
    
                Console.ReadLine();
            }
        }

  • Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    Can the category be deleted? Maybe it can't, because it's already used somewhere and deleting it would lead to inconsistent database.

  • tomhundley Profile Picture
    15 on at

    Yes it should be able to be deleted; there is nothing assigned to them.  And if that were the case, I'd hope for an HTTP status code other than success or no content/204.  Thanks for the thought though!

  • Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    Can you please test your assumption that it should be able to get deleted?

  • tomhundley Profile Picture
    15 on at

    Really?  Yes, it's tested.  It's not an assumption.  The Product Categories can be deleted from the UI without issue.  

    The UI actually uses https://...Services/ReliableCommunicationManager.svc/ProcessMessages?cmp=abc&lng=en-us& instead of making a restful call, which I was hoping to see.  

    For whatever it's worth, the UI does prompt and ask if the user wants to check if the category is referenced by other documents.  I'm wondering if that has anything to do with it, perhaps there is another method/resource that needs to be called or pass something in the body stating that the delete operation is "confirmed", however, the documentation that I can find doesn't say anything of the sort.  And again, using both Postman and an OData client in c# return success statueses from the server, although it's not deleted.

  • Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    Then I would debug the entity to see where things go wrong.

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 > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 303 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 122 Super User 2025 Season 2

#3
Siv Sagar Profile Picture

Siv Sagar 105 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans