Post

2 followers Follow
1
Avatar

Get profile_id from space_id/user_id with App authentication flow

When a users adds an item, I would like to add the user to one of the field (as a reference to a workspace member).

When I get the item ( https://developers.podio.com/doc/items/get-item-22360), I get a user_id:

"created_by": { "user_id": **** }

That's not enough information to add someone to a field, because you can't add a user to a field: that has to be a workspace member. Since I want to use the App auth flow, I can't use PodioSpaceMember ( https://developers.podio.com/doc/space-members/get-space-member-20735097): it will return PodioForbiddenError.

How can I add a user to a field?

Stephan Vierkant Answered

Please sign in to leave a comment.

17 comments

0
Avatar

Hi Stephan

 

If you set the value for the field to the following:

[{

  "type": "user",

  "id": 1234

}]

then it should work without having to do any lookups.

Christian

Christian Holm 0 votes
0
Avatar

Hi Christian,

Thanks for your suggestion, but that doesn't work for me. This is what I do (PHP):

$fields[27788373] = array("type" => "user", "id" => (int) $created_by['id']);

$update = PodioItem::update($item, array('fields' => $fields), array('hook' => false, 'silent' => true));

This is what it returns:

'error_description' =>

string

'Invalid field 27788373 ('value'): Invalid value None (null): must be integer or null or JsonifiableAdaptable or null' (length=116)

Can you see what's going wrong?

Stephan Vierkant 0 votes
0
Avatar

Hi

Sorry, I was too quick (don't thrust my memory). You need to use "value" instead of "id".

Christian

Christian Holm 0 votes
0
Avatar

Sorry, that doesn't work either:

'error_description' =>

string

'The app with id 2779441 does not have the right view on profile with id 736088'

Stephan Vierkant 0 votes
0
Avatar

The item_id is 46035989. This is what I send to the API:

27788373 (Array, 2 elements)

-
type (String, 4 characters user

-
value (Integer736088

Stephan Vierkant 0 votes
0
Avatar

I am not doing too well here. Can you try the following:

[{"value": {"type": "user", "value": 736088}}]

Christian Holm 0 votes
0
Avatar

Fixed! This was the correct value:

[{"value": {"type": "user", "id": 736088}}]

Stephan Vierkant 0 votes
0
Avatar

Yes it is. The App doesn't know about any users, you have to authorize as a user.

Carl-Fredrik Herö 0 votes
0
Avatar

Sorry, I miss read your question. The correct answer from me should have been: No it's not possible. :)

Carl-Fredrik Herö 0 votes
0
Avatar

Please let us know when you find miscategorized API operations so we can get them corrected. We have like 250 API operations so fat fingers do result in a few mislabeled items. :(

/Andreas

Andreas Haugstrup Pedersen 0 votes
1
Avatar

hi,
iam stuck on this
[{"value": {"type": "user", "id": 736088}}]

this is what i am doing but its not working

$fields[130654] = array([{"value": {"type": "user", "id": 736088}}]); //php doesnt like it

$update = PodioItem::update($item_id, array('fields' => $fields), array('hook' => false, 'silent' => true));

You said you fixed it ? can u please give me the whole code for the field variable above.

Thanks in advance

Stephen Grealy 1 vote