var data = $.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/ProjectData/Resources",
        type: "GET",
        dataType: "json",
        headers: { Accept: "application/json;odata=verbose" }

I want to access data with my Admin credentials if the current user is not Admin user.

How can I pass the Admin username and password to the rest api call in SharePoint Online.


You can't. If you could expose admin credentials on the client side they'd be accessible to all your users. Remember, JavaScript runs in the browser.

What you can do instead is write a web service that acts like a proxy using the admin credentials, and call that instead.

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.