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.

No response when updating a contact via API v2

JenniferDanyA
Participant

No response when updating a contact via API v2

When attempting to update an existing contact via the /contacts/<contactID> endpoint I recieve no content response from the server, and the contact is not updated.) The following headers are returned :

 

Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, no-cache="Set-Cookie"

Content-Type : application/json

Date: Wed, 11 Mar 2015 14:45:03 GMT

Pragma: no-cache

Server: Apache

Vary: Accept-Encoding,User-Agent

X-Mashery-Responder: prod-j-worker-us-east-1e-75.mashery.com)

X-Powered-By: 

Content-Length: 0

Connection: keep-alive

 

However when I use the test tool at https://constantcontact.mashery.com/io-docs using the same info and JSON body I receive a full response with content and the record is updated.

 

The return headers in this case are:

 

Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, no-cache="Set-Cookie"
Content-Type: application/json;charset=UTF-8
Date: Wed, 11 Mar 2015 14:31:41 GMT
Pragma: no-cache
Server: Apache
Vary: Accept-Encoding,User-Agent
X-Mashery-Responder: prod-j-worker-us-east-1d-66.mashery.com
X-Powered-By:
Transfer-Encoding: chunked
Connection: keep-alive

 

And the complete updated json object is returned. 

 

The main difference that I can see in the response headers (other than the zero content), is the server that responded.

 

I have no dificulty in adding a contact, but the update fails every time. 

 

For the record here is the JSON i'm sending. (The uri is identical as are the send headers)

 

{"company_name": "", "source_details": "IPAC Subscribe", "addresses": [{"postal_code": "", "sub_postal_code": "", "id": "d24053a0-c7fa-11e4-9069-842b2b5261ac", "city": "[REDACTED]", "address_type": "PERSONAL", "state_code": "[REDACTED]", "line1": "", "line2": "", "line3": "", "country_code": ""}], "source": "API", "email_addresses": [{"status": "ACTIVE", "email_address": "[REDACTED]", "opt_in_source": "ACTION_BY_VISITOR", "confirm_status": "NO_CONFIRMATION_REQUIRED", "id": "d1e20700-c7fa-11e4-9069-842b2b5261ac", "opt_in_date": "2015-03-11T14:28:00.000Z"}], "status": "ACTIVE", "modified_date": "2015-03-11T14:31:42.000Z", "id": "[REDACTED]", "lists": [{"status": "ACTIVE", "id": "[REDACTED]"}, {"status": "ACTIVE", "id": "[REDACTED]"}], "last_name": "Tester", "job_title": "", "first_name": "Tim", "fax": "", "notes": [], "work_phone": "", "home_phone": "", "created_date": "2015-03-11T14:28:00.000Z", "prefix_name": "M.", "middle_name": "", "confirmed": false, "cell_phone": "", "custom_fields": [{"name": "CustomField1", "label": "CustomField1", "value": "Municipal"}, {"name": "CustomField2", "label": "CustomField2", "value": "Manager"}, {"name": "CustomField3", "label": "CustomField3", "value": "UNAFFILIATED"}, {"name": "CustomField4", "label": "CustomField4", "value": "Suspended"}, {"name": "CustomField5", "label": "CustomField5", "value": "FRIEND OF IPAC"}, {"name": "CustomField6", "label": "CustomField6", "value": "Not Yet A Member"}, {"name": "CustomField8", "label": "CustomField8", "value": "Friend of IPAC signup"}, {"name": "CustomField9", "label": "CustomField9", "value": "E"}, {"name": "CustomField10", "label": "CustomField10", "value": "[REDACTED]"}, {"name": "CustomField11", "label": "CustomField11", "value": "1900-01-01"}, {"name": "CustomField7", "label": "CustomField7", "value": ""}]}

 

Any help would be greatly appreciated as this issue is stalling my development.

 

Thanks.

2 REPLIES 2
Elijah_G
Member

Hello,

 

After reviewing our HTTP access logs for your API request, I found that you received a HTTP 405 Method Not Allowed error response. This error does not include a response body, which is why there was no response. The reason for this error is that your attempt to update the contact was sent as a HTTP POST request, rather than HTTP PUT. If you change your code to use the PUT method rather than POST, it should correct the problem.

 

If you are still having any problems after this change, please let us know!

 

Please Note: I have removed some of the specific details from the JSON payload you posted to protect the identity of the contact identified within it.

 

Sincerely,

Elijah G.
API Support Engineer

Brilliant, 

 

Thank you.

 

Feeling a little dense for not seeing that. Swithching the http type to PUT fixed me right up.

Developer Portal

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

Visit Page