Unable to insert field value for PodioAppItemField
AnsweredHi,
I am creating a new item and adding an app reference. I am following the docs and have tried everything but podio fails if i try to set this value. Here is what I am doing. (I've simplified this):
_$app = new PodioApp(111); _
_$item = new PodioItem(array( 'app' => $app, 'fields' => array(), )); _
_$item->fields = array(
new PodioTextItemField('title'),
new PodioAppItemField('app-reference'),
); _
_$item->field('title')->set_value('hello');
$item->field('app-reference')->set_value(22222); _
$item->save();
In this example, 22222 is the item_id of the referenced app item. I've tried placing this value into an array as well as an associative array but I get :
*Error! *
*PodioForbiddenError [ Error ]:
/usr/local/zend/apache2/htdocs/eduserv1/trunk/fuel/vendor/podio/podio-php/lib/Podio.php @ line 238 *
Please help.
-
Hi Andreas,
Actually, I had done that at first but am now using item_id, not app_item_id. So this value actually comes from:
$parentProject = PodioItem::get_by_external_id(<<project App Id>>, $projectExternalId);
later...
$item->field('app-reference')->set_value(array('item_id'=>parentProject->item_id)); -
Hi Ben,
I think it would be a good idea to get podio-php into debug mode so you can see exactly what's going back and forth over the wire. See https://github.com/podio/podio-php#debugging--error-handling
/Andreas
-
Andreas, here is the log entry for the POST. It is trying to post to the correct app. The "parent" item_id 99641444 is correct. New new "child" id makes sense. But I get this error:
2013-11-27 16:21:16 403 POST /item/app/5799238/
2013-11-27 16:21:16 Request body: {"fields":{"title":[{"value":"xzczxc"}],"section-title":[{"value":"zczc"}],"description-of-problem":[],"type-2":[1],"status2":[1],"priority2":[1],"browser2":[1],"reporter":[{"value":"Ben Hoffman"}],"page-title":[{"value":"sdfsmsdf"}],"page-id":[{"value":"dcms-c5388464-43fc-45d9-a666-35b54790b8fc"}],"page-file":[{"value":"c_cns206_titlepage_d55.html"}],"page-link":[{"embed":15522490,"file":null}],"app-reference":[99641444]},"app":{"app_id":5799238}}
2013-11-27 16:21:16 Reponse: {"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/app\/5799238\/","query_string":"","method":"POST"},"error_description":"The app with id 5799257 does not have the right view on embed with id 15522490","error":"forbidden"} -
Andreas. Strangely, if I do not try to add the app-reference, all posts fine including the embedField. However, if I do not POST the embed field, the app reference will now POST!. Now I am focusing on that embed field which I believe I am posting properly as I do the same in other places. Weird how it's one or the other.
-
So what this is telling me is, I can add a record to the "child" app as long as I don't specify a "parent" app reference. Or, I can specify a "parent" app as long as the child has no EmbedField. BUT, if I specify a parent app AND the child has am EmbedField, the parent has some sort of rights problem with that.
Latest Log entry:
2013-11-27 16:59:29 403 POST /item/app/5799238/
2013-11-27 16:59:29 Request body: {"fields":{"title":[{"value":"xzczxc"}],"section-title":[{"value":"zczc"}],"description-of-problem":[],"type-2":[1],"status2":[1],"priority2":[1],"browser2":[1],"reporter":[{"value":"Ben Hoffman"}],"page-title":[{"value":"fdsfsfsad"}],"page-id":[{"value":"dcms-c5388464-43fc-45d9-a666-35b54790b8fc"}],"page-file":[{"value":"c_cns206_titlepage_d55.html"}],"page-link":[{"embed":15526985,"file":66238144}],"app-reference":[99641444]},"app":{"app_id":5799238}}
2013-11-27 16:59:29 Reponse: {"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/app\/5799238\/","query_string":"","method":"POST"},"error_description":"The app with id 5799257 does not have the right view on embed with id 15526985","error":"forbidden"} -
Hi Andreas,
This problem seems to be resolved. The only difference now is that I removed the urldecode() around the url string and I wrap the final value in an array ( $item->field('page-link')->set_value(array($pageLink)); )
I had tried this earlier but it DIDN'T work. Earlier than that it DID work as long as I didn't save the app-reference. Frankly I'm confused about why this is now working and since I can't debug the service layer, that's as far as I can go.
Thanks,
Ben
Please sign in to leave a comment.
Comments
12 comments