We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

405 Method not Allowed on Put

MikeA50
Health Practitioners & Centers

405 Method not Allowed on Put

I am currently getting an error(405 method not allowed) when trying to update a contact in my C# application. I am using the CC api, and it is working for everything else I need with this single exception. 

 

 

I successfully copied the JSON directly from my debug session and put it into the IO Docs page and was able to update the contact with no issue.

 

I have read this may be a network config issue on our end or at our ISP, is this possible?

 

Any input would be greatly appreciated.

5 REPLIES 5
Elijah_G
Member

Hello,

 

If you are receiving an HTTP 405 error, then that error would be produced by your webserver rather than by Constant Contact. The only time we will return a 405 error is if a request is made using an unsupported method such as OPTIONS or PATCH.

 

After doing some searching on the web about this happening with C# applications, it looks like the ability to send both PUT and DELETE normally needs to be enabled.

 

Here is an article on the IIS forums where a user seemed to be experiencing a similar issue.

 

Unfortunately there is likely not a great amount that we will be able to do, but please feel free to ask for help and we will provide what we are able.

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
MikeA50
Health Practitioners & Centers

Elijah,

 

I think there is some confusion here. My application is a windows console app. I am not accessing a webserver at my location whatsoever. I am getting this server error message from the Constant Contact API Server. From what you are saying it sounds like this a configuration issue on your end. Please advise.

 

-DOnline

Hi,

 

It might be helpful to see the code, or have you use a code snippet from me to see if you're using the correct function to update a contact.  As Elijah mentioned, you'll generally only get a 405 if you're attempting to do a call (GET/PUT/DELETE/POST) that isn't supported for the endpoint/resource you're trying to access.  

 

It could indicate you're trying to update a contact with the POST method, for example.  The UpdateContact method in the .net wrapper should be used to update contacts, and that method is configured, correctly, to PUT to a contact.  See my simple code snippet below that successfully updates a contact.

 

string apiKey = "your api key";
string accessToken = "your token";
ConstantContact cc = new ConstantContact(apiKey, accessToken);

ContactList list = cc.GetList("1"); //list you're targetting
Contact contact = cc.GetContact("2249"); //contact ID of your contact
contact.Lists.Add(list);
cc.UpdateContact(contact, false);

 

 

Best Regards,

Shannon W.

API Support Specialist

MikeA50
Health Practitioners & Centers

Hello Shannon,

 

I am using the .net wrapper.

 

_constantContact.UpdateContact(updateContact, false);

 updateContact is type "Contact".

 

The error is occuring inside the wrapper:

response = request.GetResponse() as HttpWebResponse;

 The stack trace shows the UpdateContact method, again inside the wrapper.

 

With the same basic code I have added and retrieved contacts and contact lists. This is the only unresolved issue I have.

 

FYI, I just tried your code below and get the same error.

 

-Andy

 

Hi Andy,

 

I do tend to agree with Elijah's assessment that it might be an environment issue, if you can't use the same code we do to make a successful call.  You could try updating or deleting a list as a test to see if your environment isn't allowing PUTs or DELETEs selectively.  You probably want to check your server configuration if you can't do PUTs or DELETEs.  Sorry for the inconvenience.

 

Best Regards,

Shannon W.

API Support Specialist

Developer Portal

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

Visit Page