I tried with all HTTP methods enabled for /api/user only, and it update user successfully.
But if I tried only with GET and PATCH methods enabled for /api/user , I get 'statusCode=401'.
Here is code
import { FusionAuthClient, UserRequest } from '@fusionauth/typescript-client'
...
export class FusionAuthService {
private fusionAuthClient: FusionAuthClient;
constructor(private context: Context) {
this.fusionAuthClient = new FusionAuthClient(context.config.fusionAuth.apiKey, context.config.fusionAuth.apiUrl);
}
...
public async updateUser(userId: string, userRequest: UserRequest ) {
return this.fusionAuthClient.updateUser(userId, userRequest)
.then(clientResponse => {
logger.info("User:", JSON.stringify(clientResponse.response.user, null, 2));
}).catch(logger.error);
}
here is invocation of updateUser method that happens on 'user.registration.create' event
if (user) {
const patchBody = {
user: {
email: event.user.email,
data: {
userId: user.id
}
},
}
await this.fusionAuthService.updateUser(event.user.id, patchBody);
}
Now I understand that I use updateUser method and I don't know what kind of HTTP request it used.
I have found patchUser and with it get success.
Thanks for your help.