If you call the SharePoint 2013 REST API in your applications ensure that any requests originating from the client are sent from the current web base URL to avoid returning a SafeQueryPropertiesTemplateUrl error.
If the current site is
https://tenant.sharepoint.com/sites/mysitecollection/subsite1/subsite2
then it is very important that you submit API requests as
https://tenant.sharepoint.com/sites/mysitecollection/subsite1/subsite2/_api
and NOT as any of:
https://tenant.sharepoint.com/_api
orhttps://tenant.sharepoint.com/sites/mysitecollection/_api
or evenhttps://tenant.sharepoint.com/sites/mysitecollection/subsite1/_api
The reason for this is that the current user must have access to the site addressed by the base URL of the API request (the bit before the _api
). If the user cannot access this site then the request will fail. Unfortunately it doesn’t fail in the manner you might expect (i.e. a 401 access denied exception). A request that fails in this manner will return a 500 error. The specific exception details are as follows:
Exception class:
Microsoft.Office.Server.Search.REST.SearchServiceException
Exception message:
The SafeQueryPropertiesTemplateUrl "The SafeQueryPropertiesTemplateUrl "{0}" is not a valid URL." is not a valid URL.

Paul.
Hello,
I resolved this error enable permissions level in
site settings->site permissions->permissions level->read->
Integration client features
Use remote interface
For more details
http://wp.me/pOY2A-eY