I'm trying to build a very simple JSOM app using Napa, that would list the projects created, but I'm getting the following exception:
Unexpected response from server. The status code of response is '500'. The status text of response is 'Internal Server Error'.
Microsoft.SharePoint.Client.ResourceNotFoundException
Cannot find resource for the request ProcessQuery
Here's a piece of my code:
Default.aspx
...
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/ps.js"></script>
...
App.js
// Declare global variables.
var projContext;
var projects;
$(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(GetProjects, "ps.js");
});
// Get the projects collection.
function GetProjects() {
// Display a message to the user to show we are reading the projects.
$('#spanMessage').text('Reading projects...');
// Initialize the current client context.
projContext = PS.ProjectContext.get_current();
// Get the projects collection.
projects = projContext.get_projects();
// Register the request for information that you want to run on the server.
projContext.load(projects);
// Run the request on the server.
projContext.executeQueryAsync(IterateThroughProjects, QueryFailed);
}
function IterateThroughProjects(response) {
// Get the enumerator and iterate through the collection.
var enumerator = projects.getEnumerator();
while (enumerator.moveNext()) {
var project = enumerator.get_current();
// Get the target project and then check it out. The checkOut function
// returns the draft version of the project.
var draftProject = project.checkOut();
// Specify "true" to also check the project in.
var publishJob = draftProject.publish(true);
// Register the job that you want to run on the server and specify the
// timeout duration and callback function.
projContext.waitForQueueAsync(publishJob, 30, QueueJobSent);
}
}
Unexpected response from server. The status code of response is '500'. The status text of response is 'Internal Server Error'.
Microsoft.SharePoint.Client.ResourceNotFoundException
Cannot find resource for the request ProcessQuery
Here's a piece of my code:
Default.aspx
...
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/ps.js"></script>
...
App.js
// Declare global variables.
var projContext;
var projects;
$(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(GetProjects, "ps.js");
});
// Get the projects collection.
function GetProjects() {
// Display a message to the user to show we are reading the projects.
$('#spanMessage').text('Reading projects...');
// Initialize the current client context.
projContext = PS.ProjectContext.get_current();
// Get the projects collection.
projects = projContext.get_projects();
// Register the request for information that you want to run on the server.
projContext.load(projects);
// Run the request on the server.
projContext.executeQueryAsync(IterateThroughProjects, QueryFailed);
}
function IterateThroughProjects(response) {
// Get the enumerator and iterate through the collection.
var enumerator = projects.getEnumerator();
while (enumerator.moveNext()) {
var project = enumerator.get_current();
// Get the target project and then check it out. The checkOut function
// returns the draft version of the project.
var draftProject = project.checkOut();
// Specify "true" to also check the project in.
var publishJob = draftProject.publish(true);
// Register the job that you want to run on the server and specify the
// timeout duration and callback function.
projContext.waitForQueueAsync(publishJob, 30, QueueJobSent);
}
}