When i try to execute sample batch code in Sharepoint server 2013 i'm getting the error 'Cannot find resource for the request $batch'
Int16 listRetrievalCount = 0;
if (IsPostBack)
{
// Get the host web's URL.
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
}
// Create the parent request
var batchRequest = new BatchODataRequest(String.Format("{0}/_api/", sharepointUrl)); // ctor adds "$batch"
batchRequest.SetHeader("Authorization", "Bearer " + accessToken);
using (var oDataMessageWriter = new ODataMessageWriter(batchRequest))
{
var oDataBatchWriter = oDataMessageWriter.CreateODataBatchWriter();
oDataBatchWriter.WriteStartBatch();
// Create the two child query operations.
oDataBatchWriter.CreateOperationRequestMessage(
"GET", new Uri(sharepointUrl.ToString() + "/_api/Web/lists/getbytitle('Composed Looks')/items?$select=Title"));
listRetrievalCount++;
oDataBatchWriter.CreateOperationRequestMessage(
"GET", new Uri(sharepointUrl.ToString() + "/_api/Web/lists/getbytitle('User Information List')/items?$select=Title"));
listRetrievalCount++;
oDataBatchWriter.WriteEndBatch();
oDataBatchWriter.Flush();
}
// Parse the response and bind the data to the UI controls
var oDataResponse = batchRequest.GetResponse();
Eorror is thrown in GetResponse function. Code taken from https://msdn.microsoft.com/library/office/dn903506.aspx