I am creating xml object of particular entity record and send to the server.
The code was working fine till yesterday.
Now, i am not able to send the data most of time and getting following error.
*This post is locked for comments
I am creating xml object of particular entity record and send to the server.
The code was working fine till yesterday.
Now, i am not able to send the data most of time and getting following error.
*This post is locked for comments
Hi Pawan,
Your exception is completely clear, 404 Not Found ==> your endpoint not exists (or your server not reachable).
Can you open your endpoint url with browser or outside your plugin codes (such as console app).
Other important point, you can not use IP address to call any webservice inside plugin / workflow assembly, D365 doesn't allow this, use domain / subdomain
Thanks for reply,
I am working on Dynamics 365 Online.
I able to hit my service through the plugin.
but Service endpoint throw exception
Plugin code:
WebClient webClient = new WebClient(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(string)); MemoryStream mem = new MemoryStream(); ser.WriteObject(mem, order); string data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length); webClient.Headers["Content-type"] = "application/json"; webClient.Encoding = Encoding.UTF8; serres = webClient.UploadString("xxxxxxxxxxxxxxx/.../PlaceOrder", "POST", data);
Service Code:
public string PlaceOrder(string order) { try { counter++; HttpWebRequest request = null; string destinationUrl = "api endpoint"; request = (HttpWebRequest)WebRequest.Create(destinationUrl); byte[] bytes; bytes = System.Text.Encoding.ASCII.GetBytes(order); request.ContentType = "application/xml; encoding='utf-8'"; request.ContentLength = bytes.Length; request.Method = "POST"; Stream requestStream = request.GetRequestStream(); requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode == HttpStatusCode.OK) { Stream responseStream = response.GetResponseStream(); string responseStr = new StreamReader(responseStream).ReadToEnd(); order = responseStr; } else { order = response.ToString(); } } return order; } catch (Exception exp) { return exp.Message.ToString(); } }
Hey,
Can you share the code? Hard to help with little to go on... Is this in Dynamics 365 Online or some version of OnPrem?
Good luck!
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,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156