From 65ec3441280ab0913ddcdaaf0e6483c98c718754 Mon Sep 17 00:00:00 2001 From: Tomi Tavela Date: Wed, 20 Dec 2023 13:58:25 +0200 Subject: [PATCH] Update request-digest.ts When using InjectHeaders, you can set odata=verbose. When pnpjs is updating X-RequestDigest, and calls _api/contextinfo, its using the injected headers, containing odata=verbose, and the code fails to set X-RequestDigest. So forcing to set the Accept parameter correctly, and not using the injected one. --- packages/sp/behaviors/request-digest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sp/behaviors/request-digest.ts b/packages/sp/behaviors/request-digest.ts index 4bbf74d0e..b70e827a1 100644 --- a/packages/sp/behaviors/request-digest.ts +++ b/packages/sp/behaviors/request-digest.ts @@ -47,6 +47,7 @@ export function RequestDigest(hook?: (url: string, init: RequestInit) => IDigest digest = await spPost(SPQueryable([this, combine(webUrl, "_api/contextinfo")]).using(JSONParse(),BatchNever()), { headers: { + "Accept": "application/json", "X-PnPjs-NoDigest": "1", }, }).then(p => ({