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

Announcements

No record found.

News and Announcements icon
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

  • 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
    240,744 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
    240,744 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
    240,744 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 99 Super User 2026 Season 2

#2
Paolo Cecchelli Profile Picture

Paolo Cecchelli 73 Super User 2026 Season 2

#3
Aayush Tiwari Profile Picture

Aayush Tiwari 71

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans