0

I have created an azure function which gets the site name from the end user and uses CSOM code to get the owners of a sharpoint online site collection using service account credentials. Now there are few sites where event service account doesnt have permission(Lets call them super secret sites). For this we get 401 unauthorized error and we show the same to the end user. However the issue is with the sites that doesnt exists. when the end user enters a site that doesn't exists the csom code still throws the 401 unauthorized error instead of something like "Cannot contact site at the specified URL . There is no Web named ". if I enter incorrect url in the brower I get the 404 file not found error which is the correct behavior Is it correct behavior? how can i differentiate between a super secret site and a site that doesnt exists i.e a wrong url to show the user proper error message

0

Once it throws 401 unauthorized error, I think you can directly send an HTTP request to the site using httpclient or httpwebrequest. It should return 404 FILE NOT FOUND if the site does not exist, and keep 401 unauthorized if it's a super-secret site.

BR

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.