List of products¶
Use sample below to get list of agreement products.
using Crayon.Api.Sdk;
using Crayon.Api.Sdk.Domain.Csp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ClientSdkSample
{
internal class Program
{
static async Task Main(string[] args)
{
var clientId = "XXXXXX";
var clientSecret = "XXXXXX";
var userName = "XXXX@XXXX.XXX EMAIL";
var password = "XXXXXX";
var apiUrl = "https://api.crayon.com/";
var client = new CrayonApiClient(apiUrl);
var token = client.Tokens.GetUserToken(clientId, clientSecret, userName, password).GetData().AccessToken;
var filter = new AgreementProductFilter
{
OrganizationId = XXXX
};
filter.Include.PartNumbers = new List<string>();
filter.Include.PartNumbers.Add("CFQ7TTC0LH34");
var getResult = await client.AgreementProducts.GetAsync(token, filter);
if (getResult.IsSuccessStatusCode)
{
foreach (var item in getResult.Data.Items)
{
Console.WriteLine("Product Variant id:" + item.ProductVariant.Id.ToString());
}
}
else
{
Console.WriteLine("Connection problem.");
}
}
}
}