PUT to Microsoft Graph in a tsx file

Daniel Arroyo Blanco 1 Reputation point
2021-08-17T08:40:26.663+00:00

Hello everyone, I am making a Teams application to practice, and I want to create a method in my app that changes the state of my teams.

It created a default project with Visual Studio Code to be able to use sso, and it creates tsx files for me with a specific structure.

He found information like the following:

https://learn.microsoft.com/es-es/graph/api/profilephoto-update?view=graph-rest-1.0&tabs=javascript

But trying to apply that code, I get an error (adapted to my project of course)

I first tried to make a get, and with the microsoft documentation I couldn't, I got it thanks to the following code that I found on the internet:

getPresence = async () => {

let endpoint = 'https://graph.microsoft.com/beta/me/presence';  

let graphRequestParams = {  

  method: 'GET',  

  headers: {  

    "authorization": "bearer " + this.state.graphAccessToken  

  }  

}  



//submit request to Microsoft Graph  

let response = await fetch(endpoint, graphRequestParams).catch(this.unhandledFetchError);  



//process response  

if (response) {  

  if (!response.ok) {  

    console.error("ERROR: ", response);  

    this.setState({ error: true });  

  }  

  let responseJSON = await response.json();  

  this.setState({ presence: responseJSON.availability });  

   

}  

}

However, I cannot adapt this code to achieve my goal of making a PUT that changes the state for example from available to busy.

If anyone helps me I would appreciate it.

Microsoft Teams Development
Microsoft Security Microsoft Graph
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.