Unable to insert field value for PodioAppItemField

Answered

Comments

12 comments

  • Andreas Haugstrup Pedersen

    Hi Ben,

    It would appear that you are using the app_item_id (from the URL). You need to use the item_id for the value. Go to the item you want to reference and click the little cloud icon in the right side of the grey bar at the top of the item to get the ID.

    /Andreas

    0
    Comment actions Permalink
  • Ben Hoffman

    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));

    0
    Comment actions Permalink
  • Ben Hoffman

    also tried: $item->field('app-reference')->set_value(parentProject->item_id);

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    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

    0
    Comment actions Permalink
  • Ben Hoffman

    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"}

    0
    Comment actions Permalink
  • Ben Hoffman

    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.

    0
    Comment actions Permalink
  • Ben Hoffman

    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"}

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Are kyou by any chance re-using an embed_id from another item? Embeds are only valid for the item they are originally attached to. You must create a new embed (with a fresh embed_id) for each item you are creating.

    0
    Comment actions Permalink
  • Ben Hoffman

    First I have a :

    $item->fields = array(

    new PodioEmbedItemField('page-link'),

    Then:

    $attributes = array( 'url' => urldecode($urlString) );

    $pageLink = \PodioEmbed::create( $attributes );

    $item->field('page-link')->set_value($pageLink);

    0
    Comment actions Permalink
  • Ben Hoffman

    Sorry... can't edit post above. Missing end paren but I think you get what I'm doing. Again, this works fine unless I also add a PodioAppItemField as well. If I leave it out, the PodioAppItemField works fine. It's one or the other.

    0
    Comment actions Permalink
  • Ben Hoffman

    Hi Andreas, any idea why this might be happening?

    Thanks,

    Ben

    0
    Comment actions Permalink
  • Ben Hoffman

    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

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk