Менделей Пагинация

  1. В настоящее время в группе SciTS Mendeley насчитывается 1205 ресурсов (цитирований). Однако, как бы мы ни называли метод «getDocuments» API, мы получаем только первые 1000 ресурсов. Есть ли какой-то конкретный параметр, который нам нужно передать, чтобы получить полный список ресурсов? Или есть способ сделать последующий вызов, который получит страницы данных, не возвращенные первым вызовом?

        string grantType = "client_credentials";
        string applicationID = "id";
        string clientsecret = "XXXXXXX";
        string redirecturi = "*******";
        string url = "https://api-oauth2.mendeley.com/oauth/token";
        string view = "all";
        string group_id = "f7c0e437-f68b-34df-83c7-2877147ba8f9";
        HttpWebResponse response = null;
    
        try
        {
            // Create the data to send
            StringBuilder data = new StringBuilder();
            data.Append("client_id=" + Uri.EscapeDataString(applicationID));
            data.Append("&client_secret=" + Uri.EscapeDataString(clientsecret));
            data.Append("&redirect_uri=" + Uri.EscapeDataString(redirecturi));
            data.Append("&grant_type=" + Uri.EscapeDataString(grantType));
    
            data.Append("&response_type=" + Uri.EscapeDataString("code"));
            data.Append("&scope=" + Uri.EscapeDataString("all"));
    
            byte[] byteArray = Encoding.UTF8.GetBytes(data.ToString());
    
            // Setup the Request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;
    
            // Write data
            Stream postStream = request.GetRequestStream();
            postStream.Write(byteArray, 0, byteArray.Length);
            postStream.Close();
    
            // Send Request & Get Response
            response = (HttpWebResponse)request.GetResponse();
            string accessToken;
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                // Get the Response Stream
                string json = reader.ReadLine();
                Console.WriteLine(json);
    
                // Retrieve and Return the Access Token
                JavaScriptSerializer ser = new JavaScriptSerializer();
                Dictionary<string, object> x = (Dictionary<string, object>)ser.DeserializeObject(json);
                accessToken = x["access_token"].ToString();
            }
            // Console.WriteLine("Access TOken"+ accessToken);
    
            var apiUrl = "https://api-oauth2.mendeley.com/oapi/documents/groups/3556001/docs/?details=true&items=1250";
    
            try
            {
                request = (HttpWebRequest)WebRequest.Create(apiUrl);
                request.Method = "GET";
                request.Headers.Add("Authorization", "Bearer " + accessToken);
    
                request.Host = "api-oauth2.mendeley.com";
    
                response = (HttpWebResponse)request.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    // Get the Response Stream
                    string json = reader.ReadLine();
                    Console.WriteLine(json);
                    //need this to import documents
    
                }
                              }
            catch (WebException ex1)
            {
    
                Console.WriteLine("Access TOken exception" + ex1.Message);
            }
    
    
        }
        catch (WebException e)
        {
    
            if (e.Response != null)
            {
                using (HttpWebResponse err = (HttpWebResponse)e.Response)
                {
                    Console.WriteLine("The server returned '{0}' with the status code '{1} ({2:d})'.",
                      err.StatusDescription, err.StatusCode, err.StatusCode);
                }
            }
        }
    

person quest2014    schedule 29.08.2014    source источник


Ответы (1)


Количество возвращаемых элементов по умолчанию ограничено 1000 на страницу. Для ответа с разбивкой на страницы вы должны получить некоторые дополнительные поля в ответе; особенно «items_per_page», «total_pages», «total_results».

Я подозреваю, что у вас будет две страницы, и для получения следующего результата вам нужно добавить «страница = 1».

person MendeleyStack    schedule 01.09.2014