Question

i am getting invalid error on the below error. I couldnt make out what the error was.

   url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Mega Menu')/items?$select=Sub_x0020_Heading$filter=(Main_x0020_Heading eq " + heading + ")",

Error

{"readyState":4,"responseText":"{\"error\":{\"code\":\"-1, Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The expression \\\"Sub_x0020_Heading$filter=(Main_x0020_Heading eq INFORMATION TECHNOLOGY)\\\" is not valid.\"}}}","responseJSON":{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The expression \"Sub_x0020_Heading$filter=(Main_x0020_Heading eq INFORMATION TECHNOLOGY)\" is not valid."}}},"status":400,"statusText":"error"}
Was it helpful?

Solution

You are missing the ampersand(&) before filter operator.

Modify it as below:

url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Mega Menu')/items?
$select=Sub_x0020_Heading&$filter=(Main_x0020_Heading eq " + heading + ")",
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top