Discover how to extract response headers utilizing the capabilities of the Microsoft Graph API in conjunction with the MSGraphClientFactory

I have a question that is very similar to this post: How to retrieve response headers using Microsoft Graph API

The main difference I noticed (correct me if I'm wrong) is that I am utilizing MSGraphClientFactory.getClient() from '@microsoft/sp-http' instead of { Client } from @microsoft/microsoft-graph-client.

Here's my current code :

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));

You can find the documentation for the request here.

Thank you in advance.

PS: I came across this post as well as the mentioned documentation, but none of them seemed to help. After giving it some thought, it's not surprising that the code in the client's documentation didn't work for me since I'm not using that specific client.

Answer №1

Success!

const result = 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 :",  result.headers.get("location"));

It seems including

{"state" : "archived"}
in the post request was necessary for success. This detail was not mentioned in the documentation, so I'm unsure why.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to use ngModel directive in Angular to select/unselect dynamically generated checkboxes and retrieve their values

Currently, I am working with a dataset retrieved from an API and dynamically creating checkboxes in my HTML page using the DataView component from PrimeNG. My objective is to implement a feature where users can select or deselect all checkboxes with a cli ...

Creating an array in TypeScript that supports multiple possible types, recursively, and enforces that all elements must be of the same type

I've been having difficulty creating a type that fits this specific data model: Each node can be: - native type - string, number, boolean, null, undefined - a list containing all the *same type* of nodes - a dictionary of any type of nodes ...

Is it possible to obtain Literal types for object keys dynamically in typescript?

I am looking to extract the type of object keys. Below is a generic function for objects with keys as strings: type GenericInput = { [key:string]: {value:string,type:HTMLInputTypeAttribute,placeholder:string,min?:number,max?:number,required?:boolean, err ...

When dynamically selecting an item from a dropdown menu, the object property does not display as expected when using the patchValue

When attempting to set the value for a sort object with specific type and format, I encountered an issue where it was not being rendered. Below is my code snippet using patch to set the value: let arr = <FormArray>this.myForm.controls.users; arr.c ...

What causes my Redux component to re-render when the state it's not related to changes?

My redux state structure is as follows: { entities: { cars: { byId: {}, isFetching: true }, persons: { byId: {}, isFetching: false } } } Exploring the implementation of my Person container: class PersonPag ...

Using vue-class-component: A guide on creating and setting up reactive data

I am currently working with Vue.js using TypeScript and vue-class-component. My goal is to create a custom component with reactive data. Below is the code I have so far: <template> <div> <input v-model="data.name" placeholder=" ...

Type generic in TypeScript

I'm having trouble understanding the code snippet below from redux-form export type DataSelector<FormData = {}, State = {}> = (formName: string, getFormState?: GetFormState) => (state: State) => FormData; export const getFormValues: Data ...

When working with Angular 2, it is important to note that the NgFor directive only supports binding to Iterables like Arrays. If you encounter an error message stating "Cannot find a differ supporting object '[object Object]' of type 'leaveType

After an extensive search and exploration for a solution to my problem, I found one, but unfortunately it didn't work as expected. The issue at hand involves displaying static data/list in dropdown options using TypeScript. Currently, I am working wit ...

Guide to converting TypeScript classes into functional components in ReactJS

Struggling to convert a typescript class component to functional components and encountering some issues that I can't seem to resolve. Seeking guidance on how to fix this problem. https://i.sstatic.net/QbWwo.png class component import * as React fro ...

Encountering an issue with a custom hook causing an error stating "Attempting to access block-scoped variable 'X' before its declaration."

Currently, I am in the process of developing my initial custom hook. My confusion lies in the fact that an error is being displayed, even though the function is defined just a few lines above where it's invoked. Here is the relevant code snippet: f ...

Do we really need Renderer2 in Angular?

Angular utilizes the Renderer2 class to manipulate our view, acting as a protective shield between Angular and the DOM, making it possible for us to modify elements without directly interacting with the DOM ourselves. ElementRef provides another way to al ...

What is the best way to assign TypeScript interfaces to an Input field?

Suppose I have the following interface CardDetail: export interface CardDetail { name: string; type: string; logo?: string; What is the correct way to ensure that the @Input() decorators accept this type of data? import { CardDetail } from ' ...

How to Generate a JPG File from a Leaflet Map in Angular 4 using Typescript

I am developing a custom application using Angular4 that involves integrating leaflet maps. One of the requirements is to export the current view of a map as a JPG image, capturing only the map with markers and polylines - similar to taking a screenshot. ...

Aggregate and consolidate data based on multiple criteria while ensuring data integrity and maintaining type compliance

In search of a solution, I aim to organize an array of objects by a specified number of keys and calculate the sum of values of another set of keys. For instance, consider the following array: const arr = [ { type: "triangle", color: "green", available ...

The power of RXJS's combineLatest operator

Upon using the combineLatest operator, I encountered an unexpected response when adjusting the interval duration of the first and second observables. Here is an example of the code: let intObs1$ = interval(1000).pipe(take(3)); let intObs2$ = interval( ...

The push() method encounters an error displaying the message: "Unable to append a new attribute."

Check out the code snippet below: const saveReserve = () => { if (polygons && creatingPolygon) { let last = creatingPolygon.coordinates[creatingPolygon.coordinates.length - 1][0][0]; console.log({last, polygons}) let newline = polygons. Co ...

Combining React Conetxt with useReducer and Typescript throws the error message: 'No overload matches this call'

Here is a sample of my reducer code: import { IState } from "./initialState"; import { TAction } from "./actions"; import * as types from './types'; const myReducer = (state: IState, action: TAction): IState => { const ...

Display a list of items using *ngFor in a dropdown menu without using the optgroup

Is there a way to group data from *ngFor in the dropdown selection without using optGroup? You can find the JSON file link below: JSON Data Typescript Code getProducts() { if (this.products.length < 1) { this.productService.getProducts ...

Angular 4: The parameter 'typeof CLASS' cannot be assigned to the parameter 'INTERFACE'

Exploring dynamic components in Angular has been quite interesting for me. However, I've encountered a roadblock that I'm unsure how to overcome. This is the interface I am working with: export interface InjectableComponent{ setData(data: a ...

Encountering a JavaScript/TypeScript issue that reads "Unable to access property 'Items' as it is undefined"

I encountered an issue with Javascript where I'm receiving an error message stating "Cannot read property 'Items' of undefined". The this keyword is consistently showing as undefined in the Base class. How can this problem be resolved? Coul ...