Comments (20)
Yes, we've confirmed that this is a bug in that we don't support calls that return 204 in batches, we'll update this to fix it in a future release.
from pnpjs.
The release you're referencing is very stable, so I suspect something you have set up isn't correct. I can't really help you without any code showing what you're doing and what line the error is happening on. I'm going to guess that you don't have any behaviors set up... but again just a shot in the dark without any further information.
from pnpjs.
Hi @juliemturner
Thank you for the prompt response. I'm sorry I didn't have time to create a short code to reproduce this issue. As it occurs as part of a complex piece of code.
I've worked out a compact example which causes the error:
import { graphfi } from '@pnp/graph';
import '@pnp/graph/teams';
import '@pnp/graph/batching';
import { GraphDefault } from '@pnp/nodejs';
const graph = graphfi().using(GraphDefault({
baseUrl: 'https://graph.microsoft.com',
msal: {
config: {
auth: {
clientId: '<CLIENTID>>',
clientSecret: '<CLIENTSECRET>>',
authority: '<AUTHORITY>',
},
},
scopes: [ 'https://graph.microsoft.com/.default' ]
}
}));
// The MSTeam ID we're going to test with
const TESTTEAM = '<SOME GUID>';
(async ()=>{
// Get the first channel from the Team (there seems to be a typing issue here, so we cast it to any for now)
const testChannel: any = (await graph.teams.getById(TESTTEAM).channels())[0];
console.log(`Testing with channel "${testChannel.displayName}"`);
// Create a new tab
const newTab = await graph.teams.getById(TESTTEAM).channels.getById(testChannel.id).tabs.add(
'PnPJS Test',
'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/com.microsoft.teamspace.tab.web',
{
configuration: {
contentUrl: 'https://www.google.com',
websiteUrl: 'https://www.google.com',
}
}
);
// Remove the created tab in a batched request
const [batch,execute] = graph.batched();
batch.teams.getById(TESTTEAM).channels.getById(testChannel.id).tabs.getById(newTab.data.id).delete();
try {
await execute();
} catch(error) {
console.error('Something went wrong.', error); // We the "Cannot read property 'Content-Type' of undefined" error here
}
})();
This code creates a tab in a Teams channel and successfully removes it, but still throws an error.
Calling the delete()
outside of the batch works without any error.
from pnpjs.
Ok, so to summarize the delete teams tab call works but doesn't work batched? That's a distinct possibility because not all calls work batched, but it may be something we can fix. I'll look into it further.
from pnpjs.
@juliemturner
No, the call is successful, but PnPJS throws an error, because it tries to get a response header that isn't there.
The batched call returns HTTP 204 and the tab is actually deleted.
In this case, response.headers
is undefined at this point:
pnpjs/packages/graph/batching.ts
Line 378 in 0240d02
Also... the tab deletion is an example. I've seen it with other batched deletes.
from pnpjs.
I would gladly provide a PR, but I'm not sure what would be the desired way to fix this.
Quick and dirty would be just changing the line mentioned to:
const contentType = response.headers?.["Content-Type"];
from pnpjs.
Related Issues (20)
- @pnp/graph - spfx msal v3 single sign on redirect HOT 5
- copyByPath can return an unuseable object HOT 6
- Async Iterator Pattern Type Error HOT 3
- Getfilebyserverrelativeurl return corrupted file for .docx file HOT 9
- Batching multiple lists fail HOT 4
- Custom Http request to pull RateLimit-Reset header HOT 3
- Why use the .js extension in imports? HOT 3
- Email Notification delays while send email using @pnp/sp/utilities HOT 9
- Get Version History of a List Item in one request. HOT 3
- v4 - How do I get paged items using async iterator and break only when ALL items are retrieved? HOT 3
- sendEmail from property not working HOT 3
- Update Content Type from List endpoint and not web HOT 2
- Next on cached pagination request HOT 3
- Uploading data into an Excel Spreadsheet. HOT 8
- Add/Update methods no longer returning data as of V4 HOT 3
- How can I get a list of all folders in a document library? HOT 3
- version 4 - @pnp/sp/favorites doesn't exists HOT 3
- PNP/Graph Error: No observers registered for this request. HOT 9
- Some of the SharePoint Online users are not showing in the Auto Complete or People Picker HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnpjs.