web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 2011 - Plug-In - Operation Timed-Out error while trying to do a HTTP Post in a Plug-in

(0) ShareShare
ReportReport
Posted on by 150

I'm having problems when I try to do a HTTP Post in my Plugin (in PostUpdate). I'm getting the "The Operation Has Timed Out"-Error...

Here below you have the C#-code :

                        //PUBLISH TO ROBAROV
                        WebRequest webRequest = WebRequest.Create(newUri);
                        webRequest.Timeout = 2000;
                        webRequest.ContentType = "application/x-www-form-urlencoded";
                        webRequest.Method = "POST";
                        byte[] bytes = Encoding.ASCII.GetBytes(parameters);
                        Stream os = null;
                        try
                        {
                            webRequest.ContentLength = bytes.Length;
                            os = webRequest.GetRequestStream();
                            os.Write(bytes, 0, bytes.Length);
                        }
                        catch (WebException ex)
                        {
                            throw new Exception(ex.Message);
                        }
                        finally
                        {
                            if (os != null)
                            {
                                os.Close();
                            }
                        }                                

                        //ERROR HAPPENS HERE

                        string responseText = "";
                        try
                        { // get the response
                            WebResponse webResponse = webRequest.GetResponse();
                            StreamReader sr = new StreamReader(webResponse.GetResponseStream());
                            responseText = sr.ReadToEnd().Trim();
                        }
                        catch (WebException ex)
                        {
                            throw new Exception("Error with response : " + ex.Message);
                        }

The error happens when I'm trying to get the response => webRequest.GetResponse();!

I've tried the code out in a simple "Class"-library and there it works like a charm! Is there something I'm doing wrong? The HTTP Post is to a webpage that's not in the same domain....

UPDATE : Same happens when I do the following with a webclient... And it works in a normal "Console"-application :

    private string HttpPostTest(string URL)
    {
        WebClient webClient = new WebClient();

        System.Collections.Specialized.NameValueCollection formData = new System.Collections.Specialized.NameValueCollection();
        formData["state"] = "yes";
        byte[] responseBytes = webClient.UploadValues(URL, "POST", formData);
        string Result = Encoding.UTF8.GetString(responseBytes);
        return Result;
    }

I'm getting the following error in the "Event Viewer" :

following error in the "Event Viewer" :

Inner Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Crm.Setup.DiffBuilder, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

*This post is locked for comments

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans