I am successful in getting data from host web to app web but the problem i am facing with is querying the API.
This is i am trying to do but getting error..
var getTaskByUser = function (userID) {
var hostweburl =
decodeURIComponent(
getQueryStringParameter("SPHostUrl")
);
var appweburl =
decodeURIComponent(
getQueryStringParameter("SPAppWebUrl")
);
var scriptbase = hostweburl + "/_layouts/15/";
// Load the js files and continue to the successHandler
$.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);
function execCrossDomainRequest() {
// executor: The RequestExecutor object
// Initialize the RequestExecutor with the add-in web URL.
var executor = new SP.RequestExecutor(appweburl);
executor.executeAsync(
{
url:
appweburl +
"/_api/SP.AppContextSite(@target)/web/lists/GetByTitle('Asana2')/Items?$select=Title,Category?@target='" +
hostweburl + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successHandler,
error: errorHandler
}
);
ERROR:
GET https://niisar-3b7c10c2234504.sharepoint.com/Development/SharePointApp1/_ap…ect=Title,Category?@target=%27https://niisar.sharepoint.com/Development%27
400 (Bad Request)
"{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The expression \"Title,Category?@target='https://niisar.sharepoint.com/Development'\" is not valid."}}}"
Need help. I am new to sharepoint