none
Run REST script on Time interval RRS feed

  • Question

  • Hi All,

    i have a Rest script (JSON) which is working fine, 

    how can i make this script run on time intervals.

    Thanks in advance

    Monday, November 25, 2019 4:58 PM

Answers

  • Hi,

    Yes, in SharePoint Online, we have to use webjobs to achieve it.

    Check official article below.

    Get started with Azure WebJobs for Office 365 sites

    Or using PowerShell or create console application with CSOM C# in client side, then using windows task scheduler to run it.

    Best regards,

    Dennis 


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by v k b Wednesday, November 27, 2019 10:50 AM
    Wednesday, November 27, 2019 8:47 AM
    Moderator

All replies

  • Hi

    Depends on where you run the script.


    Justin Liu Office Apps & Services MVP, MCSE
    Senior Software Engineer
    Learn Microsoft 365 from Microsoft DOCs now!
    Please Vote and Mark as Answer if it helps you.

    Tuesday, November 26, 2019 1:10 AM
  • Hi,

    The following example code for your reference.

    <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {    	    
    	setInterval(getListItem, 1000);
    });
    function getListItem(){     
    	var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('customlist')/items";
    	$.ajax({
    		url: url,
    		type: "GET",
    		headers: {
    			"Accept": "application/json;odata=verbose",
    		},
    		success: function (data) {
    			$.each(data.d.results, function(index, item){
    				console.log(item.Title);
    			});
    		},
    		error: function (error) {
    			console.log(JSON.stringify(error));
    		}
    	});
    }
    </script>

    More information:

    Window setInterval() Method

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.


    Tuesday, November 26, 2019 2:20 AM
    Moderator
  • Hi Dennis, Thanks for the reply, the above works if i keep the page open, how can i make it work like timer job, like , it has to work even when the page is closed.
    Wednesday, November 27, 2019 6:14 AM
  • Hi,

    We can create a custom timer job and use serer object model to achieve it. The following article for your reference.

    How to Create Timer Job in SharePoint 2013

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, November 27, 2019 7:06 AM
    Moderator
  • Hi Dennis, its on sharepoint online, and is there any way apart from WebJobs.

    Wednesday, November 27, 2019 8:05 AM
  • Hi,

    Yes, in SharePoint Online, we have to use webjobs to achieve it.

    Check official article below.

    Get started with Azure WebJobs for Office 365 sites

    Or using PowerShell or create console application with CSOM C# in client side, then using windows task scheduler to run it.

    Best regards,

    Dennis 


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by v k b Wednesday, November 27, 2019 10:50 AM
    Wednesday, November 27, 2019 8:47 AM
    Moderator
  • OK , will give it a try , thanks a lot 
    Wednesday, November 27, 2019 10:50 AM