I'm making rest calls to get a lists fields in a custom JS application. For some reason it's failing when I make the call through the app but when I do it in the console it works fine.

I'm using Pnpjs to make the calls, I've looked at the two requests and there's nothing different other than the Request Headers between when it's called in app vs console

enter image description here

This is my pnp.setup config:

    sp: {
        headers: {
            Accept: "application/json; odata=verbose"
    defaultCachingStore: "session", // or "local"
    defaultCachingTimeoutSeconds: 30,
    globalCacheDisable: false, // or true to disable caching in case of debugging/testing
    enableCacheExpiration: true, // added in 2.0.8
    cacheExpirationIntervalMilliseconds: 1000 // added in 2.0.8
  • Can you try by removing the header config in your code ? – Gautam Sheth Nov 14 '18 at 4:13
  • Hey, so I did try this but by default all my calls return with application/json; odata=nometadata. I trying to find a way in 2016 to return calls under odata=verbose – Batman Nov 14 '18 at 7:03
  • what version of pnp are you using ? also, can you try it as $pnp.setup({ sp: { headers: { "Accept" : "application/json; odata=verbose" } }, and check ? Notice the double quotes over accept – Gautam Sheth Nov 14 '18 at 7:19
  • I'm using version 3.0.10. I know it's not the latest but I'm not aware of any changes to the newer version that impacts http heaaders and I can't update at the moment – Batman Nov 14 '18 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.