1

In this post is explained how to invite people via API:

Active Collab send Email after User create

I created my auth Token and tried out this API/JSON Request with Powshell:

Invoke-RestMethod -Method Post -Headers $headers -Uri "https://pmo.lukad.net/api/v1/users/invite"  -Body '{email_addresses:["webmaster@lukad.com"],role:"Member"}'

Iam getting this Error:

Script failed! Last error: {"type":"InvalidParamError","message":"'email_addresses' not found in array","code":0,"file":"\/var\/www\/pmo\/activecollab\/5.13.133\/angie\/functions\/general.php
","line":826,"trace":"#0 /var/www/pmo/activecollab/5.13.133/modules/system/controllers/UsersController.class.php(134): array_required_var(Array, 'email_addresses'.....

Iam not sure what is wrong in this script. I tried out allready without clinches []

1 Answers1

0

That body does not look like a valid JSON. JSON is pretty simple, but also pretty strict. JSON parser in PHP is never trying to fix the content, it just throws an error (returns false to be more specific).

Here is a valid JSON:

{"email_addresses":["webmaster@lukad.com"],"role":"Member"}

You can use services like https://jsonlint.com to validate JSON if you are writing it manially, to avoid this type of errors.

Ilija
  • 4,105
  • 4
  • 32
  • 46