The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

API v2 updateContact problem

Highlighted
Occasional Participant

API v2 updateContact problem

Hi there,

I'm working with the new API (v2) and have been able to successfully perform a number of operations but one that I'm having trouble with is updating an existing contact. I'm using the I/O docs to test (https://constantcontact.mashery.com/io-docs) as well as the java wrapper library, both haven't worked for me.

On the I/O docs test page if I perform a GET for a specific contact I recieve back a response body with the JSON for the contact correctly (note that I have an api key and auth token already and have no issues with the OAuth process). If I then select the content (using the handy link on the test page) and paste it into request body for the PUT method for updating, I recieve:

[{
    "error_key": "json.payload.invalid",
    "error_message": "Unable to parse JSON payload."
}]

The java wrapper is failing as well with a slightly different message: CUrlRequestError [errorKey=http.status.conflict, errorMessage=There was a conflict between the supplied data and the existing resource.]]

Any help you can provide is appreciated.

Mike F
19 REPLIES 19
Highlighted
Employee

Re: API v2 updateContact problem

Hi Mike,

 

I just tested based on the steps you took, but am not able to reproduce.  What browser are you using (I wonder if the select content feature isn't working properly in it)?  If you have more than one browser, can you reproduce the problem in both?

 

What is the JSON payload for the request (&response) body?

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: API v2 updateContact problem

Hi Shannon,

 

Here's the payload, with personal details removed w/ <omit>

 

{
    "id": "3",
    "status": "UNCONFIRMED",
    "fax": "",
    "addresses": [{
        "id": "2",
        "line1": "<omit>",
        "line2": "",
        "line3": "",
        "city": "<omit>",
        "address_type": "PERSONAL",
        "state_code": "BC",
        "country_code": "ca",
        "postal_code": "<omit>",
        "sub_postal_code": ""
    }, {
        "id": "3",
        "line1": "",
        "line2": "",
        "line3": "",
        "city": "",
        "address_type": "BUSINESS",
        "state_code": "",
        "country_code": "",
        "postal_code": "",
        "sub_postal_code": ""
    }],
    "notes": [],
    "confirmed": false,
    "lists": [{
        "id": "1",
        "status": "ACTIVE"
    }],
    "source": "",
    "email_addresses": [{
        "id": "1",
        "status": "UNCONFIRMED",
        "confirm_status": "UNCONFIRMED",
        "opt_in_source": "ACTION_BY_VISITOR",
        "opt_in_date": "2008-10-03T16:04:22.282Z",
        "email_address": "mike@alluradirect.com"
    }],
    "prefix_name": "",
    "first_name": "",
    "middle_name": "",
    "last_name": "",
    "job_title": "",
    "company_name": "",
    "home_phone": "",
    "work_phone": "",
    "cell_phone": "",
    "custom_fields": [{
        "name": "CustomField2",
        "value": "not yet"
    }],
    "created_date": "2003-09-22T22:01:02.933Z",
    "modified_date": "2009-11-25T23:24:41.352Z",
    "source_details": ""
}

 

With FF 20.0, get response: "error_key": "json.payload.invalid", "error_message": "Unable to parse JSON payload."

 

With Chrome 26.0.1410.43 m I get response "error_key": "json.payload.invalid", "error_message": "Unable to parse JSON payload."

 

With IE 9.0.8112.16421 I get response "error_key": "http.status.conflict",    "error_message": "There was a conflict between the supplied data and the existing resource."

 

I'm starting to suspect that I cannot update status=UNCONFIRMED contacts. If that's the case it's np and I'll use a different contact to test with. But the different error response are a bit confusing if so...interesting that the response in IE corresponds with what I see when using the java wrapper.

 

Anyway thanks for getting back to me, let me know if anything stands out.

 

cheers,

 

Mike F
Highlighted
Employee

Re: API v2 updateContact problem

Hi Mike,

 

We do appear to be having an issue with rejecting valid JSON payloads in some cases.  We are looking into it on our side.  Thanks for reporting this, and we'll keep you posted here.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Employee

Re: API v2 updateContact problem

Hi Mike,

 

We're still working on the I/O Docs returning the invalid JSON error message with good JSON being passed in for both Chrome and Firefox.  The message you received back when using IE may actually be valid (conflict).  In IE, can you do a GET to a contact, and PUT the exact same JSON received successfully?

 

The (quite possibly valid) error about a conflict means that the system wasn't able to resolve the information in the payload with the information on file.  It could happen if a different contact ID was referenced in the payload than the contact ID referenced in the URL, for example.  It could also happen if an email address that was already in the system was referenced by another contact ID (contactID/email address mismatch).

 

Doing a GET/PUT with the same payload and to the same URL will help root that out as a cause for the failure.  Thanks!

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: API v2 updateContact problem

Hi Shannon,

 

Just tried IE again and received the same error msg: 'There was a conflict between the supplied data and the existing resource'

 

Just to be clear on the use case:

 

1) I'm retreiving an individual contact using GET: Retrieve a contact with a specified Contact ID

2) Select content in response body, copy.

3) Paste JSON into PUT: Modify a contact with specified contactID. Enter the exact same contact ID as entered during the GET. Content-Type defaults to application/json. action_by defaults to ACTION_BY_OWNER

4) Click Try it!

 

hth

Mike F
Highlighted
Employee

Re: API v2 updateContact problem

Hi Mike,

 

I've tried to replicate what you're seeing several times, but can't seem to.  The requests go through for me.  I've tried confirmed and unconfirmed contacts to see if there was some issue surrounding that, but can GET and PUT the resultant payloads just fine.  I've used IE8 and IE9 in my testing, as well as chrome and firefox.

 

Can you do a successful GET and PUT for any contact in your account?

Are you making ANY changes to the payload before doing the PUT?

 

Here is a screencast of me doing what I think you're trying to do.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: API v2 updateContact problem

Hi Shannon,

 

Still having same issues. I watched your screencast, but it does not display the response body after the PUT, just the request body which I assume is simply what was posted. Can you show what the expected response body should be? I've tested this with a few other contacts with the same result.The response body I receive contains the errors.

 

Mike

Mike F
Highlighted
Employee

Re: API v2 updateContact problem

Sorry Mike, I hadn't noticed that I was getting the error as well!  I suppose I expected it to be in large red print.  This is a defect on our side that we need to look into.  Thanks for your patience.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: API v2 updateContact problem

Just bumping this thread to see if there has been any activity on a solution.

Mike F
Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured