How to update a custom field, in contact, with API v3?

Hi everyone,

Activecampaign is kind of new for me.

I have to create a script to import a list of data and each datum is related to a specific email. I am using the API Bêta 3, maybe should I use the API 2 instead?

By doing a curl to /api/3/contacts/6929/fieldValues, I can see the field I would like to update for my test (you can see the result below ). I would like to update the field with the ID 2374 - field 29 - (actual testing value, which I added from a form, is “ceci est test #2 de testreal”). How can I update this value from the API Bêta 3? I can see this doc for API 2 : API Examples Using contact_edit, and I can see an example about how to update a deal with the API 3 here : Overview - however it is not clear. What I understand for now is that I will have to post to /api/3/contacts/6929 a json string. Can the JSON string be only something like

    { 
        "fieldValues": { 
             "id": "2374", 
            "Testreal": "field update!" 
        } 
    }  

Is that right? I am not sure and I don’t want to break anything related to my client stuff… thank you.

//// This is the output from my test at https://wamidi.godeek.cloud/test.php
    Array
    (
        [fieldValues] => Array
            (
                [0] => Array
                    (
                        [contact] => 6929
                        [field] => 1
                        [value] => 
                        [cdate] => 2017-09-26T09:34:57-05:00
                        [udate] => 2017-09-26T09:34:57-05:00
                        [links] => Array
                            (
                                [owner] => /api/3/fieldValues/2364/owner
                                [field] => /api/3/fieldValues/2364/field
                            )

                        [id] => 2364
                        [owner] => 6929
                    )

    [...]
     
                [10] => Array
                    (
                        [contact] => 6929
                        [field] => 29
                        [value] => ceci est test #2 de testreal
                        [cdate] => 2017-09-26T09:34:57-05:00
                        [udate] => 2017-09-26T09:34:57-05:00
                        [links] => Array
                            (
                                [owner] => /api/3/fieldValues/2374/owner
                                [field] => /api/3/fieldValues/2374/field
                            )

                        [id] => 2374
                        [owner] => 6929
                    )

            )

    )
1 Like

Hey @wamidimedia9334-4301,

We are adding new endpoints to the v3 API all the time, but it is still in beta. Anything for production you should use the v2 endpoints.

What I would recommend doing, which is how I test things out, is using POSTman (https://www.getpostman.com/) and a trial account to test things out before you get started.

Here is my unfinished collection for postman you can use to test things out. Once you get the hang of it there you can code it up in whatever language/library you’d like much faster - https://www.getpostman.com/collections/76b895a39dc6f7997fa2

1 Like

Thanks!

Yup I finally used the V2 endpoints and everything work fine.

1 Like

Any advances in this matter?

@acme4257 No progress, or at least no updates, on this in over a year. Hopefully we’ll hear something soon.
PLEASE vote on my idea to finish the contact endpoint in v3 API here:
https://ideas.activecampaign.com/ideas/AC-I-11589

1 Like

It looks like you can actually create/update fieldValues with v3, but since the documentation isn’t public I’d be wary of possible changes down the road. The other thing to keep in mind is that the value is dependent on the actual field type on AC (if it’s a text block, you can supply text, but if it’s a select field you actually have to look up the option ID).

To create, you can POST /fieldValues with the following JSON:

{
    "fieldValue": {
        "contact": "123",
        "field": "456",
        "value": "Test"
    }
}

To update, PUT /fieldValues/{ID} with the following JSON:

{
    "fieldValue": {
        "contact": "123",
        "field": "456",
        "value": "Test",
        "id": "789"
    }
}

I’ve noticed that v3 can be a little finicky with numeric IDs, so I always try to cast them as strings before JSON encoding but hopefully that gets fixed in the future as well.

I would also like more clear documentation about https://developers.activecampaign.com/reference#update-a-custom-field-value-for-contact. I can’t seem to get it to work, it doesn’t make any sense to me…