Isaac
asked on
REST API Endpoint error
I am using REST API with SharePoint 2013 and I want to know if the following url endpoint is legal or if there is a better way?
Error I get in my js file
js file
Thoughts?
//http://myspsite.com/nrm/_api/web/lists/getbyTitle('My_Project_Modules')/items?$select=DIR,Station,Title,Building_x0020_Number&$filter=Project_x0020_Number eq '402-CSI-001' //<--- Works when I paste it in the browser
var projNum = '402-CSI-001';
var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('My_Project_Modules')/items?$select=DIR,Station,Title,Building_x0020_Number&$filter=Project_x0020_Number eq "+projNum; //<--- Not valid when I run it in my code
Error I get in my js file
js file
function loadSPItems() {
var projNum = '402-CSI-001';
var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('My_Project_Modules')/items?$select=VISN,Station,Title,Building_x0020_Number&$filter=Project_x0020_Number eq "+projNum;//,ProjectNumber,ApprovalStatus,ProjectExecutionStatus”;
var headers = {
"accept": "application/json;odata=verbose"
}
jQuery.ajax({
url: endPointUrl,
type: "GET",
headers: headers,
success: function (data) {
console.dir(data);
},
error: function (err) {
alert("Error Occured:" + JSON.stringify(err));
}
});
}
loadSPItems();
Thoughts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome <|:-)
ASKER