Hello EveryOne,
I have 2 custom entities, the Postulacion entity and the Matricula entity,
I create the Matricula record inside the Postulacion Plugin (Stage: Pre Operation - sync) :
private Guid CrearMatricula(IOrganizationService servicio, ITracingService tracingService, Entity eMatricula, Guid gOportunidad, EntityReference erCliente) { //... Matricula.Id = servicio.Create(eMatricula); //... return Matricula.Id; }
So far so good, the problem is when within that same plugin (Now Post Operation - sync)
I try to call the Cross-entity navigation Endpoint using the recently created Matricula.Id
the endpoint response is "Not Found"
Cross-entity navigation Code :
var jCuerpo = (dynamic)new JObject();
jCuerpo.traversedpath = "ed1c90a4-d769-4089-950a-baba331db0bd,2c633484-48f8-4816-9c24-c406ee3b74cd,6d92c079-2378-4e98-93da-6a737afb779b,566bc8bc-97e8-43c5-8be3-fb15316b19b0";
jCuerpo["bpf_onetoone_matriculaid@odata.bind"] = "/onetoone_matriculas(" context.SharedVariables["MatriculaId"].ToString() ")";
string sUrlEndPoint = ""xxxx.crm2.dynamics.com/.../onetoone_1to1utppregrados(" gInstanciaFlujoId.ToString() ")";
tracingService.Trace("url Endpoint: " sUrlEndPoint);
tracingService.Trace("Cuerpo: " jCuerpo.ToString());
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
client.DefaultRequestHeaders.Add("OData-Version", "4.0");
client.BaseAddress = new Uri(sUrlEndPoint);
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("PATCH"), "")
{
Content = new StringContent(jCuerpo.ToString(), Encoding.UTF8, "application/json")
};
HttpResponseMessage response = client.SendAsync(request).Result;
The code is correct because when I replace the matriculaId with a previously created one, the call to the Endpoint ends correctly,
also the matriculaid value is always there, I have already obtained the traces and the value is there. What I have thought as the creation
of Matricula Record is done recently still does not exist before finalizing the Plugin execution (post Operation), but I am not totally convinced,
please I would appreciate any advice,
Antony