2

I'm using Flows API to create new workflows.

API: https://developers.podio.com/doc/flows/add-new-flow-26309928

I've prepared the attributes properly (by referring the API documentation). It is not working as expected and returning an error while creating flows with effects. I was able to create a flow without any effects, ie. a null flow which does nothing. But when I tried to create flow with effects, it shows error as below.

PodioServerError: An unexpected error occurred during execution.

Below given is my code part,

 $attributes = array(
            'config' => array(
                'conditions' => array()
            ),
            "effects" => array(array(
                "values" => array(
                    'attribute_id' => "comment.value",
                    'label' => "Comment",
                    'required' => true,
                    'substitutions' => array(),
                    'type' => "text",
                    'value' => "This is a test comment from flow"
                ),
                'type' => "comment.create",
            )),
            'name' => 'Test Flow via API',
            'type' => 'item.create'
        );
    PodioFlow::create('app', $appID, $attrib);

Any idea what could be the error or how to properly debug this?

Tom
  • 4,257
  • 6
  • 33
  • 49

1 Answers1

2

Can you please try:

$attributes = array(
            'config' => array(
                'conditions' => array()
            ),
            "effects" => array(array(
                "attributes" => array(array(
                    'attribute_id' => "comment.value",
                    'label' => "Comment",
                    'required' => true,
                    'substitutions' => array(),
                    'type' => "text",
                    'value' => "This is a test comment from flow"
                )),
                'type' => "comment.create",
            )),
            'name' => 'Test Flow via API',
            'type' => 'item.create'
        );

The only difference is values were replaced with attributes inside effects. That was mistype in docs, sorry, it's fixed now.

Pavlo - Podio
  • 2,003
  • 2
  • 10
  • 19
  • I've tried it with the above code. Now the error is PodioBadRequestError: "Invalid value {"required": true, "value": "This is a test comment from flow", "substitutions": [], "attribute_id": "comment.value", "label": "Comment", "type": "text"} (object): must be array" Can you please check what is wrong here? I've tried with arrays and objects and it didn't help. – Nivin V Joseph Mar 06 '17 at 05:06
  • I've updated code to `"attributes" => array(array(` from `"attributes" => array(` . Sorry, but I don't have php sandbox setup, so can't verify this code. So, please give it a try again. – Pavlo - Podio Mar 06 '17 at 13:41
  • Yes, that did the trick. thanks :) Please proceed to update the doc with "attributes" instead of "values". – Nivin V Joseph Mar 07 '17 at 06:23
  • Btw, @NivinVJoseph, can you please share some details on why you are creating flows from API? This appears to be pretty unique case, because usually it's easier to create flows from UI, so I wonder what is your use-case :) – Pavlo - Podio Mar 07 '17 at 14:21
  • @Pavio We're going to implement this copy workflow option in our [Podio Copy Tool](https://podiocopy.phases.dk) :) – Nivin V Joseph Mar 08 '17 at 12:57
  • Yes, but not advanced flows(effects) where we need to handle relations and all. We'll be trying to include that as well. – Nivin V Joseph Mar 09 '17 at 06:43
  • OK, good luck with that. Let me know if something else needed :) – Pavlo - Podio Mar 09 '17 at 12:03
  • Hi @Pavio. I was trying to update flow as per [Update Flow Documentation](https://developers.podio.com/doc/flows/update-flow-26310901). I was unable to do that for effect type "item.update.related" and found out that a "config" value was needed inside "effects" array. And it is missing in the doc. Just thought of letting you know. May help someone's time :) – Nivin V Joseph Mar 20 '17 at 11:20
  • Also, it worked only after doing the same change done in creating flow - "attributes" instead of "values" inside "effects" – Nivin V Joseph Mar 20 '17 at 11:31