sp-pnp-js batch requests failing with 400: Bad Request
See original GitHub issueHi,
I am building an Angular 5 application using sp-rest-proxy for local development. I am getting a 400 bad Request when trying to do a batch request using sp-pnp-js.
SharePoint Version : SharePoint Online sp-rest-proxy : latest sp-pnp-js: 3.0.4
const batch = pnp.sp.createBatch();
array.forEach(element => {
web.lists.getByTitle('ListName').items(element.Id).inBatch(batch).get()
.then(data => console.log(data))
.catch(error => console.log(error));
});
batch.execute().then(() => {
console.log('All is well');
});
Error:
Error: Error making HttpClient request in queryable: [400] Bad Request
at new ProcessHttpClientResponseException (exceptions.js:24)
at eval (core.js:33)
at ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:4745)
at ZoneDelegate.invoke (zone.js:387)
at Zone.run (zone.js:138)
at eval (zone.js:858)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4736)
at ZoneDelegate.invokeTask (zone.js:420)
Please let me know if you need any additional information. Thank you for your great work!
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Error-Handling - PnP/PnPjs
All errors resulting from executed web requests will be returned as an HttpRequestError object which extends the base Error . In addition to...
Read more >Updating sharepoint list items with batch pnp, in bad request
But the items are never updated, and all I get is. Error: Error making HttpClient request in queryable: [400] Bad Request. Image of...
Read more >Send an HTTP Requet to SharePoint 400 Bad Request Error
Solved: I am trying to follow the example at the following link to build a flow for PowerApps to clear a person field...
Read more >SharePoint Online: Perform Bulk Operations (Add/Update ...
The PnP Batch operations are accelerated and relatively reduce ... Here, instead of sending each request directly to the SharePoint Online ...
Read more >SharePoint Online – Markus Moeller's SharePoint Blog
npm install @pnp/sp --save. And inside the base web part class PnPJS needs to be initialized with the SharePoint context: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Changing the baseSiteUrl did the trick @koltyakov . I always used just the localhost:8080 and it worked well for single requests. I assumed that since we already specify the sharepoint site url when starting the proxy, all subsequent requests will be based off of that url. Thank you for the great work.
Oh, ok. Just wanted to be sure that batches are not misused.
Would be correct for sure.
Proxy resolves
/
assiteUrl
from settings in ordinary requests. But in multipart bodies we should be more strict. And I always recommend using same paths structure.That’s why this
import { loadPageContext } from 'sp-rest-proxy/dist/utils/env';
helper was created. The helper experts that WebpackDevServer is targeted it’s proxy to sp-proxy as well.