cancel
Showing results for 
Search instead for 
Did you mean: 
Tonight from 11:00 PM - 12:00 AM ET we need to make a few updates to our site.
We recommend finishing up your work before 11:00 PM and logging in after 12:00 AM.
Thank you for your patience while we make these important updates.

(500) Internal Server Error

SOLVED
Regular Visitor

Re: (500) Internal Server Error

Hello,

I am assuming the technical support a company that has been using Salesforce (professional) and Constant Contact together for a while. Recently, for no discernable reason, the sync between the two ceased working.

 

I installed the latest version and then added the button to the Contacts tab in Salesforce. When I use the button to upload a Salesforce contact to Constant Contact, an error is displayed "Upload Failed" and the associated comment is "Internal Server Error". The funny part is that the contact actually gets synced to Constant Contact.  Please see the attached image for more info.

 

Can you tell me what I need to do to either eliminate the error message and or help the system see that the sync actually worked?

 

Screenshot 2014-06-14 14.32.09.png

 

Thanks,

 

Eric


Screenshot 2014-06-14 14.32.09.png
Occasional Participant

Re: (500) Internal Server Error

i am faceing the Same problem please give  fix it.  below is my code and csv file
HttpWebRequest httpclient = (HttpWebRequest)WebRequest.Create("https://api.constantcontact.com/v2/activities/addcontacts?api_key=wv7crkj3rk3gy52ykqegkxqq");
string boundary = "--" + Guid.NewGuid().ToString();
string filename = "F:\\constant contact Wrapper\\Constant.csv";
httpclient.Headers.Add("Authorization", "Bearer 2269f201-044b-45f7-8015-e5e107555dd5");
// httpclient.Headers.Add("Accept", "application/json");
// httpclient.Headers.Add("content-type", "multipart/form-data");
// File fileToUse = new File();
// FileBody data = new FileBody(fileToUse);
httpclient.Method = "POST";
httpclient.ContentType = string.Format("multipart/form-data");
httpclient.Accept = "application/json";
httpclient.PreAuthenticate = true;
//string filename = "C:\\Development\\constantcontact\\emailkust.csv";
StringBuilder sb= new StringBuilder();
sb.AppendLine(boundary);
sb.AppendLine("content-disposition: form-data; name="+filename +"");
sb.AppendLine();
sb.AppendLine("Constant.csv"); //'filename
sb.AppendLine(boundary);
sb.AppendLine("content-disposition: form-data");//; name=""lists""");
sb.AppendLine();
sb.AppendLine("1") ;//' List Number
sb.AppendLine(boundary);
// sb.AppendLine("content-disposition: file; name=""data"" filename=""emailkust.csv""");
sb.AppendLine("Content-Type: text/csv");
sb.AppendLine();
using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
byte[] contents = new byte[fs.Length];
fs.Read(contents, 0, contents.Length);
sb.Append(Encoding.Default.GetString(contents));
}
sb.AppendLine(boundary );
byte[] fulldata = Encoding.Default.GetBytes(sb.ToString());
// httpclient.ContentLength == fulldata.Length;
using (Stream sw = httpclient.GetRequestStream()) {
sw.Write(fulldata, 0, fulldata.Length);
}
try {
HttpWebResponse response = httpclient.GetResponse() as HttpWebResponse;
using (StreamReader sr = new StreamReader(response.GetResponseStream())) {
//MessageBox.Show(sr.ReadToEnd());
}
} catch (WebException ex) {
using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream())) {
//MessageBox.Show("Error Message:" + e.Message + Constants.vbCr + Constants.vbLf + "Error Body: " + sr.ReadToEnd(), "Web Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Honored Contributor

Re: (500) Internal Server Error

Hi Eric,

 

This issue is a known problem that we have identified within the Constant Contact for Salesforce application. As you stated it is correctly uploading the contacts, but it is reporting errors within the application. We have submitted a request to investigate and correct the issue to our team which maintains the application and we should hopefully have an update to correct this soon.

 

Best Regards,

Elijah G.
API Support Engineer
Honored Contributor

Re: (500) Internal Server Error

Hello locherlav,

 

 

 After reviewing your code, I see that you have commented the following line:

// sb.AppendLine("content-disposition: file; name=""data"" filename=""emailkust.csv""");

 With this line commented out, there is a very important piece of information missing from the multipart request that must be included. You will need to uncomment this line and make sure that the correct filename is used here. Once you have accomplished this, you should see success.

 

If you are still seeing an error, please reply to this post with the Error Body contained in the error message.

 

Best Regards,

Elijah G.
API Support Engineer
Occasional Participant

Re: (500) Internal Server Error

   HttpWebRequest httpclient = (HttpWebRequest)WebRequest.Create("https://api.constantcontact.com/v2/activities/addcontacts?api_key=[REDACTED]");
            string boundary = "--" + Guid.NewGuid().ToString();
              string  filename = "F:\\constant contact Wrapper\\Constant.csv";
            httpclient.Headers.Add("Authorization", "Bearer [REDACTED]");
           // httpclient.Headers.Add("Accept", "application/json");
            // httpclient.Headers.Add("content-type", "multipart/form-data");
          // File fileToUse = new File();
           // FileBody data = new FileBody(fileToUse);
             httpclient.Method = "POST";
        httpclient.ContentType = string.Format("multipart/form-data");
        httpclient.Accept = "application/json";
        httpclient.PreAuthenticate = true;
           //string  filename = "C:\\Development\\constantcontact\\emailkust.csv";
            StringBuilder sb= new StringBuilder();
             sb.AppendLine(boundary);
        sb.AppendLine("content-disposition: form-data; name="+filename  +"");
        sb.AppendLine();
        sb.AppendLine("Constant.csv"); //'filename
        sb.AppendLine(boundary);
        sb.AppendLine("content-disposition: form-data; name=" + filename + "");
        //sb.AppendLine("content-disposition: form-data");//; name=""lists""");
        sb.AppendLine();
        sb.AppendLine("1") ;//' List Number
        sb.AppendLine(boundary);
        sb.AppendLine("content-disposition: form-data; name=" + filename + "");
          //   sb.AppendLine("content-disposition: file");
          //   sb.AppendLine("content-disposition: file; name=""data"" filename=""emailkust.csv""");
        //sb.AppendLine("content-disposition: form-data; filename=Constant.csv");
        sb.AppendLine("Content-Type: text/csv");
        sb.AppendLine();
            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                    byte[] contents = new byte[fs.Length];
                    fs.Read(contents, 0, contents.Length);
                    sb.Append(Encoding.Default.GetString(contents));
            }
              sb.AppendLine(boundary );
            byte[] fulldata = Encoding.Default.GetBytes(sb.ToString());
           // httpclient.ContentLength == fulldata.Length;
            using (Stream sw = httpclient.GetRequestStream()) {
    sw.Write(fulldata, 0, fulldata.Length);
}
            try {
    HttpWebResponse response = httpclient.GetResponse() as HttpWebResponse;
    using (StreamReader sr = new StreamReader(response.GetResponseStream())) {
        //MessageBox.Show(sr.ReadToEnd());
    }
} catch (WebException ex) {
    using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream())) {
        //MessageBox.Show("Error Message:" + e.Message + Constants.vbCr + Constants.vbLf + "Error Body: " + sr.ReadToEnd(), "Web Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

 

 

 

i got an error in that code:The remote server returned an error: (400) Bad Request.

please provide the my csv file is correct or not an if i can change my code?

Honored Contributor

Re: (500) Internal Server Error

Hello locherlav,

 

I believe that this code you are working on is a conversion of an existing code to create a bulk upload fom VB.NET to C#. During the conversion process, several important parts of the multipart request were broken. I have taken the time to correct the code and you should see success with the code below. Please take a moment to read the comments in the code, as they are relevant to having it work properly.

 

Code:

HttpWebRequest httpclient = (HttpWebRequest)WebRequest.Create("https://api.constantcontact.com/v2/activities/addcontacts?api_key=wv7crkj3rk3gy52ykqegkxqq");
string boundary = "--" + Guid.NewGuid().ToString();
string filename = "F:\\constant contact Wrapper\\Constant.csv";
httpclient.Headers.Add("Authorization", "Bearer 2269f201-044b-45f7-8015-e5e107555dd5");
httpclient.Method = "POST";
httpclient.ContentType = string.Format("multipart/form-data");
httpclient.Accept = "application/json";
httpclient.PreAuthenticate = true;

StringBuilder sb= new StringBuilder();
sb.AppendLine(boundary);
sb.AppendLine("content-disposition: form-data; name=\"file_name\"");
sb.AppendLine();
sb.AppendLine("Constant.csv"); // filename
sb.AppendLine(boundary);
sb.AppendLine("content-disposition: form-data; name=\"lists\"");
sb.AppendLine();
sb.AppendLine("1"); // Constant Contact List ID Number
sb.AppendLine(boundary);
sb.AppendLine("content-disposition: file; name=\"data\" filename=\"emailkust.csv\"");
sb.AppendLine("Content-Type: text/csv");
sb.AppendLine();
using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
    byte[] contents = new byte[fs.Length];
    fs.Read(contents, 0, contents.Length);
    sb.Append(Encoding.Default.GetString(contents));
}
sb.AppendLine(boundary + "--");
byte[] fulldata = Encoding.Default.GetBytes(sb.ToString());

using (Stream sw = httpclient.GetRequestStream()) {
    sw.Write(fulldata, 0, fulldata.Length);
}
try {
    HttpWebResponse response = httpclient.GetResponse() as HttpWebResponse;
    using (StreamReader sr = new StreamReader(response.GetResponseStream())) {
        // add code here to display the contents from sr.ReadToEnd() to see the response from ther server
    }
} catch (WebException ex) {
        using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream())) {
            // add code here to display the contents from sr.ReadToEnd() to see the response from ther server
            // add code here to display e.Message to see a shorter error message
        }
}

 

If you are still having problems, please post the detailed error message here so that I can assist you.

 

Best Regards,

Elijah G.
API Support Engineer
Member

Re: (500) Internal Server Error

I am having this problem as well.  Any help would be greatly appreciated.

Member

Re: (500) Internal Server Error

<span id="j_id0:errors"><span id="j_id0:errors:j_id3:j_id4:0:j_id5">
<div class="message warningM3" role="alert">
<table border="0" cellpadding="0" cellspacing="0" class="messageTable" style="padding:0px;margin:0px;">
<tbody><tr valign="top">
<td>
<img alt="WARNING" class="msgIcon" src="/s.gif" title="WARNING">
</td>
<td class="messageCell"><div id="j_id0:errors:j_id3:j_id4:0:j_id5:j_id6:j_id8" class="messageText"><span id="j_id0:errors:j_id3:j_id4:0:j_id5:j_id6:j_id9">
<h4>Warning:</h4></span>Upload failed. See "Comment" column in the table below.<br></div>
</td>
</tr>
<tr>
<td></td>
<td>
</td>
</tr>
</tbody></table>
</div></span></span>

Regular Visitor

Re: (500) Internal Server Error

I have same problem, what's going wrong? We need Fix it as soon as possible. 

Honored Contributor

Re: (500) Internal Server Error

Hello,

 

Regarding issues with Constant Contact for Salesforce, we have assigned the development team responsible for that application to begin working on this error message. I have been testing this issue personally and in my testing so far it appears that the imports are completing successfully, but the application is showing an error message when it should not be. At this time I do not yet know the exact ETA for when this will be resolved, but you should still be able to update your contact lists from Salesforce.

 

If you are having problems with your contacts not importing at all, please let me know!

 

Best Regards,

Elijah G.
API Support Engineer