Re: Can't add contact

Regular Participant

Re: Can't add contact

I already tried to enter that link, but it says "Application data not found for key". I already have my API key created. Why is this happening, or am i missing something?

 

Thanks for your help

17 REPLIES 17
Employee

Hey Marcie,


Can you provide us with your code so we can see why you are getting that error returned?

 

 

Ryan Davis
Quality Engineer
Regular Participant

Hi, I'm using your C# Sample Code. I've already modified the web.config file and added my username, password and mi API Key, but when i try to add a contact i'm getting this exception: System.Collections.Generic.KeyNotFoundException: The given key was not found in the dictionary at line 963: data.AppendFormat(OptInSource{0}/OptInSource", optSourceNames[contact.OptInSource The thing is my key is correct, so i don't know what's going on exactly. Hope you can help me, please. I'm using Visual Studio 2010, i don't know if that affects. Hope you can help me, please

Regular Participant

The class is ContactComponent by the way.

Hi Marcia,

 

I will need to see the code that you modified so I can troubleshoot it for you.

 

 

Ryan Davis
Quality Engineer
Regular Participant

Hi Ryan,

 

  I've only modified the web.config file like this:

 

<configuration>

       <appSettings>

           <add key = "APIKey"  value= "apikey" >

           <add key = "username" value = "username" >

           <add key= "password" value = "password">

      </appSettings>

      <connectionStrings/>

      <system.web>

          <compilation debug= "true">

          <authentication mode = "Windows">

     </system.web>

</configuration>

 

That's the ony thing. The other code is the sample C# code that i downloaded from your page. Btw I'm connected to a proxy server, i don't know if that's affecting me, i'm getting an authentication error message too. Thanks for your time.

 

 

 

Hi Marcia,

 

The code is indicating that the OptInSource dictionary is not finding an entry for the OptInSource value you set.  My best guess is that you did not set an OptInSource at all for the Contact and it's passing a 'null' value instead, which would throw this error.  Try this instead:

 

contact.OptInSource = ContactOptSource.ActionByCustomer;

 

Should fix your problem.

Dave Berard
Senior Product Manager, Constant Contact
Regular Participant

Ok, but i still have the authentication issue. I'm connected to a proxy and when i run the project it throws this message: Account authentication failed. I tried in another PC without proxy and it did well. Do you know how to run it with proxy wihout problems? Do i have to add something else to the program?

 

Thanks :smileyhappy:

Regular Participant

I'm getting this error message when i run the solution: the remote server returned an error: (407) Proxy Authentication Failed :(

Regular Participant

I can't access that page, why is that? =S

 

Thanks

Hey Marcia, That was in regards to some spam that was posted on our board.  You dont need to worry about that. 

Ryan Davis
Quality Engineer

Hi Marcia,

 

Looks like the problem is that you are not setting the Credential value for the Proxy Server.  Thus, when we try to validate that the Proxy is valid and not trying to spoof your request, we can't and throw a 407 error.  I've not done any work with this before, however there is a post on the MSDN support forums for how to set the credentials for a Proxy Server here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/83bafcd0-5bab-4cb9-96cf-a53ce132c7ab/

 

Setting the Proxy end point and credential cache should resolve the error you're seeing.

 

Dave Berard
Senior Product Manager, Constant Contact
Occasional Participant

OMG, can't believe it but now i'm having a new issue. I'm getting this error now: The remote server returned an error: (400) Bad Request. Do you know how can i fix this. Thanks in advance =)

Hey Carlos,

 

Can you please post your XML so we can take a look at what you are trying to post.  Also if you can supply the URI you are posting too that would be great.

 

 

Ryan Davis
Quality Engineer
Regular Participant

Hi again,

 

       I'm using your sample code, but when I run the project on the server i'm getting this exception:

 

Security Exception was caught

Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

 

Is in this line: GetResponseStream(newUri(authenticationData.AccountServiceDocumentUri), authenticationData);

 

This is the method of the class Utility.cs

 

publicstaticvoid IsValidUserAuthentication(AuthenticationDataauthenticationData)

{

ValidateAuthenticationData(authenticationData);

try

{

// try to access the Service Document resource// it will throw a WebException if Constant Contact credentials are invalid

GetResponseStream(

newUri(authenticationData.AccountServiceDocumentUri), authenticationData);

}

catch (Exceptione)

{

thrownewConstantAuthenticationException("Account authentication failed", e,

authenticationData.Username);

}

}

 

 

Any ideas, please? =S

 

Thanks in advance

 

Hey Marcia,

 

Based off the error that you are receiving I found apost on microsofts boards that explain how they fixed this issue by editing their web-config file.   You can find the link by clicking here.

 

Please let me know if this solved your issue.

Ryan Davis
Quality Engineer
Occasional Participant

Hi again,

 

    No, I'm strill having the same issue. Any other idea, please?

 

Thanks

Hey Carlos,

 

A 400 error is based on the XML that you are passing in.  Can you please post your XML.

Ryan Davis
Quality Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page