How to ContinuationToken REST api.partnercenter RRS feed

  • Question

  • I'm trying to get all customers from the PartnerCenter API using in a REST request.
    It brings me up to 100 ("items" list) customers, and a ContinuationToken.
    How do I use this continuation Token to bring the following "part"?
    Wednesday, May 3, 2017 8:48 PM


All replies


    In first place yu must determinate the size of the request: e.g. size=100

    Now, the respons object will have "next" and "previous" links. This is how I mapped them:

    public class CustomerAPIResponseModel
            public CustomerAPIResponseModel()
                items = new List<CustomerAPIModel>();
                links = new CustomerAPIResponseLinks();
            public string continuationToken { get; set; }
            public int totalCount { get; set; }
            public List<CustomerAPIModel> items { get; set; }
            public CustomerAPIResponseLinks links { get; set; }
        public class CustomerAPIResponseLinks
            public CustomerAPIResponseLinks()
                self = new CustomerAPIResponseLink();
                next = new CustomerAPIResponseLink();
                previous = new CustomerAPIResponseLink();
            public CustomerAPIResponseLink self { get; set; }
            public CustomerAPIResponseLink next { get; set; }
            public CustomerAPIResponseLink previous { get; set; }
        public class CustomerAPIResponseLink
            public CustomerAPIResponseLink()
                headers = new List<CustomerAPIResponseLinkHeader>();
            public string uri { get; set; }
            public string method { get; set; }
            public List<CustomerAPIResponseLinkHeader> headers { get; set; }
        public class CustomerAPIResponseLinkHeader
            public string key { get; set; }
            public string value { get; set; }

    Then, using the uri, method, and the header you will make the next request to get the next (or previous) customers.

    The Uri, method, and header key will be predefned. The next request will be like this:

    public static RespuestaObjeto<CustomerAPIResponseModel> SearchContinuationCustomers(string continuationToken, bool isNext, string sa_Token)
                //This is the link that comes in the request
                string seekOperation = isNext ? "Next" : "Previous";
                var endpoint = "" + seekOperation;
                var request = (HttpWebRequest)HttpWebRequest.Create(endpoint);
                request.Method = "GET";
                request.ContentType = "application/json";
                request.Accept = "application/json";
                request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
                request.Headers.Add("x-ms-tracking-id", Guid.NewGuid().ToString());
                request.Headers.Add("Authorization", "Bearer " + sa_Token);
                //The continuation token with the key from de response
                request.Headers.Add("MS-ContinuationToken", continuationToken);
                var respuesta = new RespuestaObjeto<CustomerAPIResponseModel>();
                    var httpWebResponse = (HttpWebResponse)request.GetResponse();
                    if (httpWebResponse.StatusCode >= HttpStatusCode.OK &&
                        httpWebResponse.StatusCode <= HttpStatusCode.NoContent)
                        using (var reader = new StreamReader(httpWebResponse.GetResponseStream()))
                            var responseContent = reader.ReadToEnd();
                            respuesta.Modelo = Json.Decode(responseContent, typeof(CustomerAPIResponseModel));
                            respuesta.Exito = true;
                        return respuesta;
                    respuesta.Exito = false;
                    respuesta.Detalle = httpWebResponse.StatusDescription;
                catch (WebException exception)
                return respuesta;

    I'm using it in an MVC project. In the customer list view I put next and previous links at the bottom part of the table.

    Thursday, May 4, 2017 4:43 PM
  • They'll help you over here.



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Thursday, May 4, 2017 4:45 PM