
andreyyuri0408
(usa Manjaro Linux)
Enviado em 10/12/2024 - 14:33h
estou criando uma automação com meu sistema integrado, porem não estou conseguindo vincular usuarios a grupo utilizando a api. alguem ja enfrentou este problema ou ja realizou esta ação e poderia me dar uma ajuda por favor?
async create(createUserDto: CreateUserDto) {
const sessionToken = await this.authService.getSessionToken();
const hash = crypto.createHash('sha1');
hash.update(`senhaSegura123`);
const setor = await this.findSetor(createUserDto.nmSetor);
const headers = {
'App-Token': process.env.GLPI_APP_TOKEN,
'Session-Token': sessionToken,
'Content-Type': 'application/json',
};
const { data } = await firstValueFrom(
this.httpService.post(
`${this.baseUrl}User`,
{ input: {
name: `${createUserDto.firstname}.${createUserDto.realname}`,
firstname: createUserDto.firstname,
realname: createUserDto.realname,
phone: createUserDto.phone,
groups_id: setor.id,
is_active: 1
} },
{ headers },
),
);
await firstValueFrom(
this.httpService.post(
`${this.baseUrl}UserEmail`,
{
input: {
users_id: data.id,
email: createUserDto.email,
},
},
{ headers },
),
);
return data;
}
está seria minha função atualmente porem ele não está vinculando pelo id do grupo