Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Getting Error while Pe...
Finance forum

Getting Error while Performing Delete Action on D365 F&O Via Odata Call

(0) ShareShare
ReportReport
Posted on by 135

Hi All,

I am working on ODATA CRUD concept in F & O data entities. I stuck in ODATA delete call, while deleting the values in data entities, Below is the code i used to delete the data entity values, actually I am receiving the 404 Error, 

Could any one help me to implement the delete call, or a sample to delete the F & O Data entity Values via ODATA.

Data entity usedSecurityUserRoleAssociations

public async Task<string> DeleteAsync(AXEntity entity)
{
    var fullUrl = ApiUrl + entity.LogicalName + "(";
    foreach (var a in entity.Attributes)
    {
        fullUrl = fullUrl + a.Key + "='" + a.Value.ToString() + "',";
    }
    var request = new HttpRequestMessage(new HttpMethod("Delete"), fullUrl)
    {
        Content = new StringContent("{}", Encoding.UTF8, "application/json")
    };
    var response = await _baseAuthorization.GetHttpCliente().SendAsync(request);
    string isSuccess = ResponseValidator.EnsureSuccessStatusCode(response);
    return isSuccess;
}

 

Thanks

Praveen

  • Community Member Profile Picture
    on at
    RE: Getting Error while Performing Delete Action on D365 F&O Via Odata Call

    I have the exact same issue trying to delete SecurityUserRoleOrganizations using the OData REST API.

    I've even tried it on other entities with composite keys but still receive a 404 error. Given the lack of documentation from Microsoft (for this API and others) I can only assume that their OData implementation can't handle composite keys.

    One thing you might be missing in your example @Praveen, is the OrganizationType. From what i've found this value is part of the composite key, but as it is an Enum you need to reference it like this: OrganizationType=Microsoft.Dynamics.DataEntities.OMInternalOrganizationType'LegalEntity'

    Something else worth mentioning, I've even tried to do this Microsoft Flow. Strangely, the "Get record" connector returns an ItemInternalId value when you get records from the SecurityUserRoleOrganizations entity, but this still can't be used to reference the individual record so it can be deleted.

  • GP Development community Profile Picture
    135 on at
    RE: Getting Error while Performing Delete Action on D365 F&O Via Odata Call

    Hi Ada,

    Thanks for the response

    Yes, i am able to retrieve the data in browser by the query i am passing in code, below is the error which i am actually getting.

    Delete_5F00_User_5F00_Role_5F00_Organizations_5F00_Http404.png

    Thanks

    Praveen

  • Jie G Profile Picture
    on at
    RE: Getting Error while Performing Delete Action on D365 F&O Via Odata Call

    Hi Praveen,

    404 means the data entity you're looking for does not exist on the server. Have you viewed the URL using the browser, can you see the entity is available?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,274 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,947 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans