I am struck here badly, Have been trying different options but no use.
I have two entities and have to create an association between these two.
I have the following code to achieve this.
var clientURL = parent.Xrm.Page.context.getClientUrl(); var req = new XMLHttpRequest() req.open("POST", encodeURI(clientURL + "/api/data/v8.0/new_experiencetopgs"), true); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json;charset=utf-8"); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.onreadystatechange = function () { if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status == 204) { var accountUri = this.getResponseHeader("OData-EntityId"); } else { var error = JSON.parse(this.response).error; } } }; var experiencetopgs = new Object(); //String Field experiencetopgs.new_name = Math.random()+"ExperienceGroup"; var experienceId =parent.Xrm.Page.data.entity.getId().substring(1, 37); //Lookup experiencetopgs["new_exppgexperience@odata.bind"] = "/***_experiences("+experienceId+")" experiencetopgs["new_exppracticegroup@odata.bind"] = "/new_experiencetopgs("+practiceGroupId+")" jObj=JSON.stringify(experiencetopgs).replace(/ /g,''); var response = req.send(jObj);
When it comes to ***_experiences, it's not accessible, I tried to directly access this entity using web API URL.
server/.../v8.0***_experienceses
Response :
{ "error":{ "code":"","message":"Resource not found for the segment '***_experienceses'.",
"innererror":{ "message":"Resource not found for the segment '***_experienceses'.",
"type":"Microsoft.OData.Core.UriParser.ODataUnrecognizedPathException",
"stacktrace":"at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.ParsePath(ICollection`1 segments)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)\r\n at Microsoft.OData.Core.UriParser.ODataUriParser.Initialize()\r\n at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath, ODataUriResolverSetttings resolverSettings, Boolean enableUriTemplateParsing)\r\n at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath)" } } }
*This post is locked for comments
Hello prashanth.kamasamudram,
I had the same error.
I resolved the problem open the metada with XRMtoolbox and there I can my setentityname was "why_pricingruleses" instead "why_pricingrules". I don't know why the system save the plural name instead singular name
I resolved the problem with this
Best Regards
Hi Prashanth,
Try using the following URL.
url: Xrm.Page.context.getClientUrl() + "/api/data/v8.0/new_experiencetopges"
Try using the plural name of the entity.
Can you share a screenshot of the custom entity information?
Hi Prashanth,
I did not try it, but maybe this would work:
- Add that entity to a new solution
- Export your solution
- Open customizaitons.xml
- Find <EntitySetName> tag
- Add your plural name there
- Repackage and import back to CRM
If, somehow, you can't find EntitySetName tag at all, it follow "attributes/>" in my case, so try adding it then:
</attributes>
<EntitySetName>tcs_lookupconfigs</EntitySetName>
<IsDuplicateCheckSupported>0</IsDuplicateCheckSupported>
PS. I was sure I saw this link just the other day.. could not find it right away - some useful reading there, too:
community.dynamics.com/.../crm-2016-web-api-and-plural-names
Hi Alex,
It seems like this is the reason Web API is unable to find the reference to Entity.
Is there any way to update this and give proper name?
Kind Regards
Prashanth
Hi Alex,
Checked it, its showing null.
Kind Regards
Prashanth
Thank you for ur response, I did import this solution and generated the code.
Following is the code which got generated.
var entity = {}; entity["new_exppgexperience@odata.bind"] = "/null()"; entity["new_exppracticegroup@odata.bind"] = "/new_practicegroups()"; entity.new_name = ""; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", datatype: "json", url: Xrm.Page.context.getClientUrl() + "/api/data/v8.0/new_experiencetopgs", data: JSON.stringify(entity), beforeSend: function(XMLHttpRequest) { XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0"); XMLHttpRequest.setRequestHeader("OData-Version", "4.0"); XMLHttpRequest.setRequestHeader("Accept", "application/json"); XMLHttpRequest.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); }, async: false, success: function(data, textStatus, xhr) { var uri = xhr.getResponseHeader("OData-EntityId"); var regExp = /\(([^)]+)\)/; var matches = regExp.exec(uri); var newEntityId = matches[1]; }, error: function(xhr, textStatus, errorThrown) { Xrm.Utility.alertDialog(textStatus + " " + errorThrown); } });
If you see at the third line of code, we got null in place of the entity name.
entity["new_exppgexperience@odata.bind"] = "/null()";
the entity is there and is being used but is not accessible by external code it seems.
Hi,
did you try to see your custom entity "set" name in the XrmToolBox Metadata Browser?
I believe that's the name you should be using, so it might be different somehow
I know you stated that you checked the schema names. Are they in the correct case as I think its case sensitive.
Or you could use the CRM REST Builder to generate the code for you: github.com/.../CRMRESTBuilder
I have also tried to install metadata browser and check for entity name and schema names, Everything is correct and also tried using the plural name. nothing is working.
IS there any chance of some metadata setting for an entity which is blocking wep api from accessing this entity?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156