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 :
Customer experience | Sales, Customer Insights,...
Answered

Unified v Legacy Xrm.WebApi.online.execute

(0) ShareShare
ReportReport
Posted on by 45

I am trying to use Xrm.WebApi.online.execute(retrieveSharedPrincipalsAndAccessRequest).then(success,failure)

It works fine on the legacy gui, however it fails on the unified interface.

Does anybody know why?

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Martin,

    Where did you get retrieveSharedPrincipalsAndAccessRequest value from?

  • Martin CPA Profile Picture
    45 on at

    Hi,

    Thanks for replying.

    var parameters = {};

    var target = {};

    target.new_apprenticeshipflightid = "4E328192-B815-EA11-A811-000D3AB297A5";

    target["@odata.type"] = "Microsoft.Dynamics.CRM.new_apprenticeshipflight";

    parameters.Target = target;

    var retrieveSharedPrincipalsAndAccessRequest = {

    Target: parameters.Target,

    getMetadata: function() {

    return {

    boundParameter: null,

    parameterTypes: {

    "Target": {

    "typeName": "mscrm.crmbaseentity",

    "structuralProperty": 5

    }

    },

    operationType: 1,

    operationName: "RetrieveSharedPrincipalsAndAccess"

    };

    }

    };

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Ok. That is something. What error do you get?

  • Martin CPA Profile Picture
    45 on at

    All that is posted in the console as the error.message is

    "A failure occurred in Wep Api in Dynamics 365."

    Not very helpful!

  • AJ-22040756-0 Profile Picture
    on at

    Hi Partner,

    Are you getting any error in Unified interface while using Xrm.WebApi.online.execute(retrieveSharedPrincipalsAndAccessRequest).then(success,failure)

  • Martin CPA Profile Picture
    45 on at

    Hi,

    Nothing at all in the Unified interface. So I am posting error to console.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    So what error do you get in the console?

  • Martin CPA Profile Picture
    45 on at

    All that is posted in the console as the error.message is

    "A failure occurred in Wep Api in Dynamics 365."

    Not very helpful!

  • Martin CPA Profile Picture
    45 on at

    So, I have undertaken some more testing.

    In CRM REST builder and legacy gui this works fine, yet when I run it in the Unified Interface I get an error (nothing is actually reported, other than it failed)

    The interesting thing is. The documentation states that the function retrieveSharedPrincipalsAndAccess  should only work with a specific set of entities, yet it works with this custom entity in the REST builder and the the legacy gui!

    In case it is of relevance. the url sending the request appears to have null metadata when sending from the Unified interface according to the console log...

    https://xxxxxxxxxxxxx.crm4.dynamics.com/api/data/v9.0/RetrieveSharedPrincipalsAndAccess(Target=@Target,getMetadata=@getMetadata)?@Target=%7B%22new_apprenticeshipflightid%22%3A%228881AC59-CF11-EA11-xxxx-000D3AB2928C%22%2C%22%40odata.type%22%3A%22Microsoft.Dynamics.CRM.new_apprenticeshipflight%22%7D&@getMetadata=null

    var parameters = {};
    var target = {};
    target.new_apprenticeshipflightid = "8881AC59-CF11-EA11-A811-xxxxxxx";
    target["@odata.type"] = "Microsoft.Dynamics.CRM.new_apprenticeshipflight";
    parameters.Target = target;

    var retrieveSharedPrincipalsAndAccessRequest = {
       Target: parameters.Target,

       getMetadata: function() {
          return {
             boundParameter: null, 
             parameterTypes: {
                 "Target": {
                     "typeName": "mscrm.crmbaseentity",
                     "structuralProperty": 5
                  }
             },
          operationType: 1,
          operationName: "RetrieveSharedPrincipalsAndAccess"
         };
       }
    };
    console.log(retrieveSharedPrincipalsAndAccessRequest)
    Xrm.WebApi.online.execute(retrieveSharedPrincipalsAndAccessRequest).then(
         function success(result) {
             if (result.ok) {
                 var results = JSON.parse(result.responseText);
                 console.log(results)}
          },
    function(error) {
             console.log(error.message);
            }
    );

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hello Martin and Andrew,

    I took the same scenario on my instance, I reproduce the same bug. Indeed, the error is the following:

    {
        "error": {
            "code": "0x8006088a",
            "message": "Resource not found for the segment 'RetrieveSharedPrincipalsAndAccess'.",
            "innererror": {
                "message": "Resource not found for the segment 'RetrieveSharedPrincipalsAndAccess'.",
                "type": "Microsoft.OData.UriParser.ODataUnrecognizedPathException",
                "stacktrace": "   at Microsoft.OData.UriParser.ODataPathParser.CreateDynamicPathSegment(ODataPathSegment previous, String identifier, String parenthesisExpression)\r\n   at Microsoft.OData.UriParser.ODataPathParser.CreateFirstSegment(String segmentText)\r\n   at Microsoft.OData.UriParser.ODataPathParser.ParsePath(ICollection`1 segments)\r\n   at Microsoft.OData.UriParser.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)\r\n   at Microsoft.OData.UriParser.ODataUriParser.Initialize()\r\n   at System.Web.OData.Routing.DefaultODataPathHandler.Parse(String serviceRoot, String odataPath, IServiceProvider requestContainer, Boolean template)\r\n   at System.Web.OData.Routing.DefaultODataPathHandler.Parse(String serviceRoot, String odataPath, IServiceProvider requestContainer)\r\n   at Microsoft.Crm.Extensibility.ODataV4.Routing.CrmODataPathHandler.<>c__DisplayClass1_0.b__0()"
            }
        }
    }

    pastedimage1590842667918v3.png

    So I did some more research so that I could correct the problem: 

    Xrm.webApi add a parameter to the request: 

    yourOrganization.crm4.dynamics.com/.../RetrieveSharedPrincipalsAndAccess(Target=@Target,getMetadata=@getMetadata)?@Target={"@odata.id":"accounts(43488de2-195e-ea11-a811-000d3a45bff9)"}&@getMetadata=null

    The error does not occur again after manually removing this parameter from the request .

    pastedimage1590843048136v4.png

    I don't know if it's a system bug. Maybe Andrew can shed some light on that. 

    Edit: 

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/retrievesharedprincipalsandaccess?view=dynamics-ce-odata-9

    RetrieveSharedPrincipalsAndAccess function normally accepts only one parameter.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans