- Issue created by @ovilla
- 🇩🇪Germany jurgenhaas Gottmadingen
Failed execution of Create discussion (Activity_0ogtuaz) from ECA New node (process_mjo7jgs) for event Drupal\eca_content\Event\ContentEntityInsert: Validation errors: [users] must be of type array.
What action plugin is actually giving you this error message?
Can you provide the plugin configuration you used for that in your ECA model?
- 🇲🇽Mexico ovilla
Thanks for the answer jurgenhaas.
It is an action plugin created by the HTTP Client Manager module, with that action I'm trying to request an API of rocket.chat to create a room, and among other things I want to send a list of users to join that room, but I need to send them as an array as described here:
https://developer.rocket.chat/reference/api/rest-api/endpoints/rooms/roo...
I have 2 files to describe the API to be used with HTTP Client Manager, these are:
src/api/rocket_chat.yml
name: "rocket.chat API" apiVersion: "1.0" description: "Client wrapper for the rocket.chat API." imports: - "resources/rooms.yml"
src/api/resources/rooms.yml
operations: CreateDiscussion: httpMethod: "POST" uri: "rooms.createDiscussion" summary: "Create discussion" parameters: X-Auth-Token: location: "header" default: "token" X-User-Id: location: "header" default: "userid" Content-Type: location: "header" default: "application/json" prid: type: "string" location: "json" description: "Parent room ID of the discussion." required: true t_name: type: "string" location: "json" description: "Discussion name." required: true users: type: "array" location: "json" description: "Array of users to join in the discussion, if not provided, it will be an empty array. (Note: if provided, it must be an array)." required: false default: [] items: "$ref": "Users" pmid: type: "string" location: "json" description: "Parent message ID (if the discussion comes from a message)." required: false reply: type: "string" location: "json" description: "The reply of the discussion." required: false responseModel: "CreateDiscussionResult" models: Users: type: "string" location: "json" CreateDiscussionResult: type: "object" location: "json" properties: success: location: "json" type: "boolean" discussion: location: "json" type: "object"
My testing model in BPMN.iO for ECA looks like this:
And this is what my action looks like:
The php error that I have mentioned above, occurs because I don't know how to send the users as an array. In the previous image I have tested with: [ "foo", "bar", "test" ]
- 🇩🇪Germany jurgenhaas Gottmadingen
That sounds like an issue for the HTTP Client Manager module then. The action plugin expects an array, but a config form can only always receive strings. So, that action plugin needs to be modified such that it converts the input into an array after it has received an encoded string, e.g. as json or yaml.
- Status changed to Closed: works as designed
8 months ago 11:09am 29 March 2024 - 🇮🇹Italy aronne
Hi @ovilla,
the HttpConfigRequestForm class converts strings written in JSON format to array and objects.
That's why it works when you use Http Config Requests written by using their original form.
I don't know how BPM.io is building this form but I think it's missing this "little" part// ... case 'array': case 'object': $element['#type'] = 'textarea'; $element['#rows'] = 12; $element['#description'] .= '<div class="json-help">' . $this->t('Example') . ': <small><pre>' . $this->getJsonHelp($param) . '</pre></small></div>'; $element['#attributes']['placeholder'] = $this->t('Enter data in JSON format.'); $element['#value_callback'] = [$this, 'jsonString']; $element['#element_validate'][] = [ $this, 'validateJson', ]; break; //....
I don't think this problem is caused by HTTP Client Manager module itself since it works fine on this side.