question

GBSSharePointAdmin-6622 avatar image
0 Votes"
GBSSharePointAdmin-6622 asked GeffLombardi-3232 commented

How to access Sharepoint REST API in my function app

My function app is triggered via an external webhook, whenever it is triggerd i want to update data in a list in my sharepoint site, I tried following the steps here (https://www.c-sharpcorner.com/blogs/setting-for-sharepoint-online-to-accessible-from-external-environment) but i'm getting 404 error as a response everytime, is there any other way to access sharepoint rest api from my azure function? Please Help

My code snippet from my node.js function that i tried for authentication (I've hidden the sensitive credentials with star)
const formData = new FormData();

     formData.append('grant_type', 'client_credentials');
     formData.append('client_id', '***@****');
     formData.append('client_secret', '*****');
     formData.append('resource', '00000003-0000-0ff1-ce00-000000000000/***@****);
        
     const res = await axios.post('https://accounts.accesscontrol.windows.net/******/tokens/OAuth/2', formData, {
           headers: {
             'Content-Type':'application/x-www-form-urlencoded'
         }
     });
sharepoint-dev
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @GBSSharePointAdmin-6622 ,

I am currently doing some research on this issue, will let you know as soon as possible.

1 Vote 1 ·

Hey thank you for your help, but i just found this solution (https://www.c-sharpcorner.com/article/integrating-sharepoint-data-into-node-js-with-access-token/), seems to be working, thanks!

0 Votes 0 ·
RaytheonXie-MSFT avatar image RaytheonXie-MSFT GBSSharePointAdmin-6622 ·

Hi @GBSSharePointAdmin-6622 ,

Glad that you found the solution to this problem. Thanks for your sharing.

As a best practice, if you solve one issue or find a solution by yourself, we suggest you post your solution/finding as an answer, and accept it via "Accept Answer" button, which will help others who have this similar issue find correct solution quickly in the future. Thanks for your understanding.

If you have any concern, please feel free to reply.

0 Votes 0 ·

Hi I'm getting the same issue 404 when trying to get an auth token, I have checked client_id, client_secret, resource, tenant id in url and all correct. I can successfully generate a token via Postman using the same details I have in code. Any resolution for this issue ?

0 Votes 0 ·

0 Answers