Hello!
I am writing Plugin on Account PostCreate. In this plugin I want to reach external webservice which is public. I need to send the record to external base. unfortunetaly I have some problems with http assembly dependencies. any workaround or suggestions please?
s
public override void ExecutePlugin() { Account account = ((Entity)context.InputParameters["Target"]).ToEntity<Account>(); var model = CreateModel(account); RunAsync(model).GetAwaiter().GetResult(); } static async Task RunAsync(Model model) { client.BaseAddress = new Uri("uri/.../methodname"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { await SendRequest(model); } catch (Exception e) { throw new InvalidPluginExecutionException(e.Message); } } } static async Task<MODEL> SendRequest(MODEL model) { HttpResponseMessage response = await client.PutAsJsonAsync( $"<RequestData>" + $"<FirstField>{model.FirstField}</FirstField>" + $"<SecondField>{model.SecondField}</SecondField>" + $"</RequestData>", model); response.EnsureSuccessStatusCode(); model = await response.Content.ReadAsAsync<Model>(); return model; }