Post

3 followers Follow
0
Avatar

Create items having "contact" type fields.

Hi,

I wanted to create a item in a particular app with a "contact" type field. Here is how i tried(php).

$response = $api->item->create($app_id, array('fields' => array( array('external_id'=>$externalid, 'values'=>array('value'=>array('name'=>$username, 'mail'=>array($sender)))))));

But in my log, it says

Invalid field 16135717 ('value'): Invalid value {u'mail': [u' sriyan.31@gmail.com'], u'name': u'Sriyan Sampath'}: Must be Integral 

I think this is regarding the format of a "contact" type field. If so I want to know how to submit them.

Can any one help me to fix this.

Thank you.

Sriyan Sampath Answered

Please sign in to leave a comment.

6 comments

0
Avatar

Hi Andreas,

Thank you in advance. Now It's working.

Sriyan Sampath 0 votes
Comment actions Permalink
0
Avatar

This is my code:

$profile_attributes = array(

'address' => $street,

'zip' => $postcode,

'city' => $city,

'organization' => $company,

'country' => $countryName,

'phone' => $telephone,

'mail' => $mail

);

PodioContact::create($space_id,$profile_attributes);

This is my error log: 

"You cannot use Thomas in this field as they are a space contact and you are using the contact field to share the item. Please remove them to continue."

"Invalid value "Ha Noi" (string): must be array"

Seth Helgeson 0 votes
Comment actions Permalink
0
Avatar

Hi Seth,

You have multiple issues. If you look at the model definition you will see that some properties are arrays and not strings: https://github.com/podio/podio-php/blob/master/models/PodioContact.php

So when you get the error "Invalid value.... (string) must be array" it means that.... you are sending a string where you should be sending an array. Three of your properties above should be arrays.

I will also encourage you to update your version of podio-php if it's older than two weeks as I've improved the error messages (it'll include the request body so you can see what property is causing the problem).

As for your other issue: It looks like an item field is configured to accept Workspace Members and share the item with them while you are trying to add a Workspace Contact as a value to the field. Modify your app so the contact field takes contacts and not members.

/Andreas

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Hi,  I just cannot figure out how to create a contact with the Python API.

There seems to be no mapping for POST /contact/space/{space_id}/

Help?

 

Gracias!

Local Harvest 0 votes
Comment actions Permalink
0
Avatar

Never mind..  figured it out.  There's no Contact class in the python wrapper.  I just added one with just a "create" method in it.

Local Harvest 0 votes
Comment actions Permalink