cancel
Showing results for 
Search instead for 
Did you mean: 

Property was found but is not permitted at this location. #customfields

SOLVED
Highlighted
Occasional Participant

Property was found but is not permitted at this location. #customfields

Hi I am trying to use PHP & CC's API to attach a custom date field to a contact entry but cannot figure out how to setup the custom fields array.


$contact['custom_fields'] = array(
array( 'duedate' => array( 'name' => 'duedate' , 'value' => $due_date) )
);

 

Here is the response I am getting from CC's api server:

 

Array ( [headers] => Array ( [cache-control] => private, no-cache, no-store, max-age=0, must-revalidate, no-cache="Set-Cookie" [content-encoding] => gzip [content-type] => application/json;charset=UTF-8 [date] => Mon, 28 Jul 2014 21:08:44 GMT [pragma] => no-cache [server] => Apache [vary] => Accept-Encoding,User-Agent [x-mashery-responder] => prod-j-worker-us-east-1b-30.mashery.com [x-powered-by] => [content-length] => 172 [connection] => Close ) [body] => [{"error_key":"json.field.invalid","error_message":"#/custom_fields/0/duedate: Property was found but is not permitted at this location."},{"error_key":"json.field.missing","error_message":"#/custom_fields/0/name: Property is required but not found."},{"error_key":"json.field.missing","error_message":"#/custom_fields/0/value: Property is required but not found."}] [response] => Array ( [code] => 400 [message] => Bad Request ) [cookies] => Array ( ) [filename] => )

 

What am I doing wrong!?

Tags (2)
9 REPLIES 9
Honored Contributor

Re: Property was found but is not permitted at this location. #customfields

Hello,

 

In this case, what you're running into is a structure issue with how you're assembling the custom field. The format that is used in JSON notation is an array of objects. In order to accomodate this, you code should look like this:

$contact['custom_fields'] = array(
(object)array( 'name' => 'duedate' , 'value' => $due_date)
);

 What I am doing here is to create an array of arrays that have been converted to objects. If you implement it in this style, it should work for you.

 

Best Regards,

Elijah G.
API Support Engineer
Occasional Participant

Re: Property was found but is not permitted at this location. #customfields

Hi I tried setting up my custom fields array like this:

 

Array
(
    [status] => ACTIVE
    [lists] => Array
        (
            [0] => Array
                (
                    [id] => 1154777811
                )

        )

    [email_addresses] => Array
        (
            [0] => Array
                (
                    [status] => ACTIVE
                    [email_address] => gogogo@gmail.com
                )

        )

    [first_name] => 
    [last_name] => 
    [custom_fields] => Array
        (
            [0] => Array
                (
                    [name] => duedate
                    [value] => 07 31 2014
                )

        )

)

 And this was the response I got:


[body] => [{"error_key":"json.regex.mismatch.custom_fields","error_message":"#/custom_fields/0/name: This attribute value must be of the format 'CustomFieldNN'"}]
    [response] => Array
        (
            [code] => 400
            [message] => Bad Request
        )

 

And then I tried turing my array of custom fields into an object before I insert them into the main array like you mentioned to do but still I did not have any success. This time I did get a new error message though:

 

Array
(
    [status] => ACTIVE
    [lists] => Array
        (
            [0] => Array
                (
                    [id] => 1154777811
                )

        )

    [email_addresses] => Array
        (
            [0] => Array
                (
                    [status] => ACTIVE
                    [email_address] => gogogo7@gmail.com
                )

        )

    [first_name] => 
    [last_name] => 
    [custom_fields] => Array
        (
            [0] => stdClass Object
                (
                    [name] => duedate
                    [value] => 07 31 2014
                )

        )

)

//Response is below
<hr>Array
(
    [headers] => Array
        (
            [cache-control] => private, no-cache, no-store, max-age=0, must-revalidate, no-cache="Set-Cookie"
            [content-encoding] => gzip
            [content-type] => application/json;charset=UTF-8
            [date] => Thu, 31 Jul 2014 17:31:25 GMT
            [pragma] => no-cache
            [server] => Apache
            [vary] => Accept-Encoding,User-Agent
            [x-mashery-responder] => prod-j-worker-us-east-1c-999.mashery.com
            [x-powered-by] => 
            [content-length] => 143
            [connection] => Close
        )

    [body] => [{"error_key":"json.regex.mismatch.custom_fields","error_message":"#/custom_fields/0/name: This attribute value must be of the format 'CustomFieldNN'"}]
    [response] => Array
        (
            [code] => 400
            [message] => Bad Request
        )

    [cookies] => Array
        (
        )

    [filename] => 
)

 Thank you for taking the time to help me.

CTCT Employee

Re: Property was found but is not permitted at this location. #customfields

Hi,

 

You should be able to do change the custom field name to something like below so that the API can map the custom field and doesn't give you that error. Currently, the PHP library only supports custom fields named as CustomFieldxx where xx is 01-15.

 

 [custom_fields] => Array
        (
            [0] => Array
                (
                    [name] => CustomField01
                    [value] => 07 31 2014
                )

        )

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

Occasional Participant

Re: Property was found but is not permitted at this location. #customfields

So in other words I need to create a new custom field and name it CustomField01 instead of 'duedate', or that maybe this error rests within the PHP kit and I could modify it to not worry about the custom field name? 

 

Otherwise how will CC know to map CustomField01 to duedate? 

Occasional Participant

Re: Property was found but is not permitted at this location. #customfields

Hello I also wanted to mention that we are not using the constant contact PHP kit to send data to the API. We are using a custom coded connector using CURL and POST. So if there are limitations to what we can name the custom field that I believe these limitations exist on the API side and not within our code structure. 

CTCT Employee

Re: Property was found but is not permitted at this location. #customfields

Hi,

 

That is correct--the limitation is not just with the PHP library, it's with the entire API. We can only map custom fields that are named as custom fields, like CustomFieldn, where n=1-15 with no leading 0's in "n" (the bare API doesn't need CustomField01, it needs "CustomField1").

 

I hope that's clear, and let me know if you have issues using custom fields even when named as above. We've documented the limitation here:

 

http://developer.constantcontact.com/docs/contacts-api/api-gui-func.html

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

Occasional Participant

Re: Property was found but is not permitted at this location. #customfields

Thank you verry much shannon. We managed to solve this for our client and are extremely grateful for the time you spent with us in finding a solution. 

 

 

Occasional Visitor

Re: Property was found but is not permitted at this location. #customfields

Dealbreaker

Moderator

Re: Property was found but is not permitted at this location. #customfields

Hello,

Thank you for your feedback. While this is a limitation of our V2 API, our new V3 API will address this when it is available very shortly this year.

Please let me know if you have any other questions!

Sincerely,
David B.
API Support Specialist