Add Sharepoint Online list item using pure JavaScript
-
20-02-2021 - |
Pregunta
I am trying to do the following:
I have a Wordpress site where I have created a form. On submit
event I want to send the data to my Sharepoint Online list. The problem I am facing is the fact that the solution needs to be build entirely with JavaScript and/or jQuery.
I have seen multiple examples of people doing it but all of them somehow are having client context
or _spPageContextInfo
available. That is not the case with me.
My question is: Is there a way just send the data to the list using simple POST
request?
Solución
OutSide of SharePoint Online Site, it's necessary to get the access token for authentication purpose.
A solution is to register a SharePoint App and get the access token with this request:
Then use the access token in the request to handle data:
Here is a detailed blog for reference:
Accessing SharePoint Data using Postman (SharePoint REST API)
Postman is a test purpose, you can convert the request above into Jquery ajax for coding.