async function addBotToUser(userId) {
const YOUR_ACCESS_TOKEN ="token"
const url = `https://graph.microsoft.com/v1.0/users/${userId}`;
const headers = {
Authorization: `Bearer ${YOUR_ACCESS_TOKEN}`,
'Content-Type': 'application/json'
};
const body = { "teamsApp@odata.bind": `https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/7eaf42b9-cf06-4d8d-b51d-20fabb7bbbb6` };
try {
const response1 = await axios.get(url, {
headers: {
Authorization: `Bearer ${YOUR_ACCESS_TOKEN}`,
'Content-Type': 'application/json'
}
});
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(body),
});
if (!response.ok) {
const errorData = await response.json();
console.error('Error:', errorData);
throw new Error(`HTTP error! Status: ${response.status}`);
}
console.log('App added successfully:', await response.json());
} catch (error) {
console.error('Error adding bot to user:', error);
}
}
The above thing is always gives not found error