koltyakov / sp-rest-proxy

🌐 SharePoint API Proxy for local development
MIT License
172 stars 43 forks source link

Proxy Error: Cannot read properties of null (reading 'toString') (see more in sp-rest-proxy console) #149

Closed kadut001 closed 2 years ago

kadut001 commented 2 years ago

Response Error { "readyState": 4, "responseText": "Proxy Error: Cannot read properties of null (reading 'toString') (see more in sp-rest-proxy console)", "status": 400, "statusText": "Bad Request" }

porxy-iisue

Console Log Message

GET: https://redacted.sharepoint.us/_api/web/siteusers? Error TypeError: Cannot read properties of null (reading 'toString') at OnDemand.saveAuthData (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:83:44) at OnDemand.getAuth (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:38:28) at Object.getAuth (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\node-sp-auth\lib\src\index.js:16:76) at SPClient. (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\sp-rest-proxy\dist\utils\client.js:69:51)
at step (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\sp-rest-proxy\dist\utils\client.js:44:23) at Object.next (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\sp-rest-proxy\dist\utils\client.js:25:53) at C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\sp-rest-proxy\dist\utils\client.js:19:71 at new Promise () at __awaiter (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\sp-rest-proxy\dist\utils\client.js:15:12) at SPClient.fetch (C:\Users\kofi.adutwum\Documents\Page\sandbox\node_modules\sp-rest-proxy\dist\utils\client.js:65:20)

I'm trying to use on demand electron credentials for this proxy. Any solution to this issue?

Thank you!

koltyakov commented 2 years ago

Hi @kadut001,

It's definitely auth thing. On-Demand might be picky to Electron version.

Could you try separating concerns by checking auth via https://github.com/koltyakov/node-sp-auth-troubleshoot raw minimal console approach?

If doesn't work please post to auth library repo https://github.com/s-KaiNet/node-sp-auth

kadut001 commented 2 years ago

Hi @koltyakov,

Thank you. It resolved my problem!

smailsw commented 2 years ago

@kadut001 i have the same issue, can you provide me please with your solution ? thank you

kadut001 commented 2 years ago

Hi @smailsw

Here are my solution

  1. git clone https://github.com/koltyakov/node-sp-auth-troubleshoot
  2. cd node-sp-auth-troubleshoot
  3. npm install
  4. npm run test -- --env uat

I have to run npm run test -- --env uat every 24 hours because the cookies expire but you can put the commands in batch script and have the batch on a scheduler.

Please let me know if it does not work