Pregunta

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"}
¿Fue útil?

Solución

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 + ")",
Licenciado bajo: CC-BY-SA con atribución
scroll top