Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Unanswered

Consume WEB API in CRM plugin returning "Server Unavailable"

Posted on by 115

Hi guys, i want to consume WEB API from Dynamics CRM plugin, but returning "503: Server Unavailable"

using (MemoryStream serializeAssignmentWO = new MemoryStream())
    {
        AssignmentWO std = new AssignmentWO();
        std.AssignmentWONo = "123457";
        std.AssignmentDate = "2021-06-08";
        std.CustAcct = "10000514";
        std.Address = "Karawaci";
        std.TapValue = "Test";
        std.Longitude = 0;
        std.Latitude = 0;
        std.CableDropPortNo = 0;
        std.FixTemp = "Test";

        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AssignmentWO));

        WebRequest request = WebRequest.Create("http://bmjkt-000037:9000/crmapi/api/RequestWONoise");
        request.Method = "POST";
        request.ContentType = "application/json";
        request.ContentLength = 0;
                          

        serializer.WriteObject(serializeAssignmentWO, std);


        StreamReader sr = new StreamReader(serializeAssignmentWO);

        string ser_result = sr.ReadToEnd();

        throw new InvalidPluginExecutionException("Result: "   request.GetResponse());
    }
                        
public class AssignmentWO
    {
        [DataMember]
        public string AssignmentWONo { get; set; }
        [DataMember]
        public string AssignmentDate { get; set; }
        [DataMember]
        public string CustAcct { get; set; }
        [DataMember]
        public string Address { get; set; }
        [DataMember]
        public string TapValue { get; set; }
        [DataMember]
        public int Longitude { get; set; }
        [DataMember]
        public int Latitude { get; set; }
        [DataMember]
        public int CableDropPortNo { get; set; }
        [DataMember]
        public string FixTemp { get; set; }
        }

If i test using Fiddler, its returning: success

  • RE: Consume WEB API in CRM plugin returning "Server Unavailable"

    Hello, I recommend you to see this link and review it with what you have done, I hope this help:

    + docs.microsoft.com/.../how-to-send-data-using-the-webrequest-class

    Thanks!

    Community Support Team - Esteban

    If this Post helps, then please consider Accept as solution to help the other members find it more quickly.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans