static private List <ItemSense.Item> GetItems() { List <ItemSense.Item> itemsToReturn = new List <ItemSense.Item>(); try { // Create an ItemsEndpointOptions object to specify the // filter(s) to use for the GET request ItemSense.ItemsEndpointOptions itemsFilter = new ItemSense.ItemsEndpointOptions(); string nextPageMarker = null; do { itemsFilter.SetPageMarker(nextPageMarker); // Create the full path to the Items show (i.e. GET) endpoint // from default ItemSense URI and the defined filter values string ShowApiEndpointPath = "/data/v1/items/show" + itemsFilter.GetFullOptionsString(); string ItemSenseShowItemsApiEndpoint = SolutionConstants.ItemSenseUri + ShowApiEndpointPath; string itemSenseData = GetItemSenseData(ItemSenseShowItemsApiEndpoint); // Now convert the raw JSON into an Items class // representation ItemSense.Items GetResultData = JsonConvert.DeserializeObject <ItemSense.Items>( itemSenseData ); itemsToReturn.AddRange(GetResultData.ItemList); nextPageMarker = GetResultData.NextPageMarker; }while (null != nextPageMarker); return(itemsToReturn); } catch { throw; } }
/// <summary> /// This program performs a GET request to the Items endpoint of the /// ItemSense instance specified in the SolutionConstants class in /// the SolutionItems project in order to demonstrate the usage of /// the nextPageMarker parameter in the returned JSON object /// </summary> /// <param name="args"> /// Command line parameters ignored. /// </param> static void Main(string[] args) { try { // Create an ItemsEndpointOptions object to specify the // filter(s) to use for the GET request ItemSense.ItemsEndpointOptions itemsFilter = new ItemSense.ItemsEndpointOptions(); string nextPageMarker = null; // Set a small page size to increase the chance that the // nextPageMarker property in the returned JSON will have // a value itemsFilter.SetPageSize(2); Console.WriteLine("Items data:"); do { itemsFilter.SetPageMarker(nextPageMarker); // Create the full path to the Items show (i.e. GET) endpoint // from default ItemSense URI and the defined filter values string ShowApiEndpointPath = "/data/v1/items/show" + itemsFilter.GetFullOptionsString(); string ItemSenseShowItemsApiEndpoint = SolutionConstants.ItemSenseUri + ShowApiEndpointPath; string itemSenseData = GetItemSenseData(ItemSenseShowItemsApiEndpoint); // Now convert the raw JSON into an Items class // representation ItemSense.Items GetResultData = JsonConvert.DeserializeObject <ItemSense.Items>( itemSenseData ); // Now iterate through the list of items and output in // CSV format foreach (ItemSense.Item currentItem in GetResultData.ItemList) { Console.WriteLine(currentItem.itemToCsvString()); } nextPageMarker = GetResultData.NextPageMarker; }while (null != nextPageMarker); // Wait for the user to say when to close the application Console.WriteLine("Press <Enter> to exit application."); Console.ReadLine(); } catch (Exception ex) { // Print out the details of any exception that occur Console.WriteLine("Exception: {0} ({1}){2}", ex.Message, ex.GetType(), (null == ex.InnerException) ? string.Empty : Environment.NewLine + ex.InnerException.Message ); } }
static private List<ItemSense.Item> GetItems() { List<ItemSense.Item> itemsToReturn = new List<ItemSense.Item>(); try { // Create an ItemsEndpointOptions object to specify the // filter(s) to use for the GET request ItemSense.ItemsEndpointOptions itemsFilter = new ItemSense.ItemsEndpointOptions(); string nextPageMarker = null; do { itemsFilter.SetPageMarker(nextPageMarker); // Create the full path to the Items show (i.e. GET) endpoint // from default ItemSense URI and the defined filter values string ShowApiEndpointPath = "/data/v1/items/show" + itemsFilter.GetFullOptionsString(); string ItemSenseShowItemsApiEndpoint = SolutionConstants.ItemSenseUri + ShowApiEndpointPath; string itemSenseData = GetItemSenseData(ItemSenseShowItemsApiEndpoint); // Now convert the raw JSON into an Items class // representation ItemSense.Items GetResultData = JsonConvert.DeserializeObject<ItemSense.Items>( itemSenseData ); itemsToReturn.AddRange(GetResultData.ItemList); nextPageMarker = GetResultData.NextPageMarker; } while (null != nextPageMarker); return itemsToReturn; } catch { throw; } }