0

I asking the exact question as this post here : How to get a response headers using Microsoft graph API

The only difference (to me?) is that i'm using MSGraphClientFactory.getClient() from '@microsoft/sp-http' instead of { Client } from @microsoft/microsoft-graph-client.

My code so far :

const Rawresponse =  graphClient.api("/teams/" + groupID + '/archive')
    .version('v1.0')
    .responseType("raw")
    .post((error, responseRaw) => {
        console.log(error);
        console.log(responseRaw);}
    ).then(response => console.log("then response : ", response.header));

Doc about the request itself.

Thanks in advance

PS : found this post along with the mentionned doc but nothing work. Afterthought : not quite suprising that the code in the client's doc doesn't work since I'm not using the client.

Titou Titou
  • 23
  • 1
  • 8
  • I understand that it's maybe dumb to use MSGraphClientFactory.getClient() when @/microsoft-graph-client existe, but I don't know why and don't feel like updating the whole project without knowing. – Titou Titou Jan 20 '23 at 16:54

1 Answers1

0

Found it !

const response = await graphClient
            .api("/teams/" + groupID + '/archive')
            .version('v1.0')
            .responseType("raw")
            .post({ "state": "archived" } , (error, resp, rawresponse) => {
                console.log("Error : ", error);
                console.log("Response : ", resp);
                console.log("RawResp :", rawresponse);
            });
        console.log("Location :",  response.headers.get("location"));

Apparently I needed to unclude {"state" : "archived"} as context of the post request. I isn't stated in the doc so I'm not sure why

Titou Titou
  • 23
  • 1
  • 8