Add group members api calling issue

Hi,
I’m modifying the react code base for admin delete extension and as part of feature letting users add members to any given group. I’m following this api:

I’m correctly passing the Token and other payload info, however, when I use the Axios or Node request both calls is resulting in error, please see the following example:

var request = require("request");

var options = { method: 'PATCH',
  url: 'https://opensimspoc.us8.webtask.io/{guid}/api/groups/{group_id}/members',
  headers: { authorization: 'Bearer token,
  data:  [ "id1", "id2" ] }
 };

request(options, function (error, response, body) {
  if (error) throw new Error(error);
  console.log(body);

This is given me error “value must be array”.

If you guys can point me to a example of how to correctly call this api and pass user(S) to any given group to be added.

Please see this thread similar issue faced by other user:

Thanks.

Hi @asif.sayed,

It looks like you are missing a quote in Bearer token.

Can you confirm that is not the issue?

Thanks,
Dan

Yes I confirm, missing quote is not the issue, you can try calling this end point from any external client no matter how I try add member to group or adding single member to multiple groups both fails. I’ve granted full access in my machine to machine client. Surprising, I can read and even remove user from group but not allowing to add.

Can you add the member to the group in the dashboard? You can view the request there if you use Chromes Network dev tool. The extension dashboard is built off of the API, so if you can do it there you should be able to do it via a patch request.

Also, I would like to confirm you are including the user id correctly. It should be in this format ["auth0|4rg6715b584db630dc44ada27"]

Let me know,
Dan

Hi Dan,
Thanks for the response. Yes, we are able to add and remove users from group using the Dashboard. But we dont want to give dashbaord access rights to certain users, that is why we are building the custom UI. Here is a test i am doing using Nodejs, and see i am crrectly sending the data :

var options = { method: ‘PATCH’,
url: ‘https://example.us8.webtask.io/example/api/groups/example/members’,
headers: {
‘Content-Type’: ‘application/json’,
‘authorization’: ‘Bearer MYTOKENHERE’,
},
data: [ ‘auth0|example’, ‘auth0|example’ ]
};

request(options, function (error, response, body) {
if (error)
throw new Error(error);

console.log(body);
});

If you require the client id and secret to test it on your side, we would be happy to provide. In meanwhile can you do a test on your side using NODE or any other JS client to see if your PATCH api call works outside of dashboard?

Thanks,
Asif

edited: to remove unique data

Thanks for letting me know you got a solution.

Resolved using Fetch instead of Axios.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.