Archived: This repository is no longer actively maintained. Please use Occtoo SDK instead. The code remains available for reference.
Wrapped httpclient used to create a Nuget package for calling onboarding.
-
Open your solution and add the package through nuget.
-
Create a instance of the OnboardingServiceClient and provide your Provider-Id and -Secret.
(Follow these steps to setup your Provider, if you do not have one.)
-
Call one of the four overloads of StartEntityImportAsync
private readonly string dataProviderId = config["providerid"];
private readonly string dataProviderSecret= config["providersecret"];
static async Task Main(string[] args)
{
var enties = new List<DynamicEntity>
{
new DynamicEntity
{
Key = "1",
Properties= {new DynamicProperty { Id= "name", Value = "number one" }}
},
new DynamicEntity
{
Key = "2",
Properties= {new DynamicProperty { Id= "name", Value = "number two" }}
}
};
var onboardingServiceClient = new OnboardingServiceClient(dataProviderId, dataProviderSecret);
var response = await onboardingServiceClient.StartEntityImportAsync(dataSource, enties);
if(response.StatusCode == 202)
{
// Data was onboarded!
}
}private readonly string dataProviderId = config["providerid"];
private readonly string dataProviderSecret= config["providersecret"];
private readonly string dataSource = "Media";
static async Task Main(string[] args)
{
var onboardingServiceClient = new OnboardingServiceClient(dataProviderId, dataProviderSecret);
var fileToUpload = new FileUploadFromLink(
"https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
"googlelogo_color_272x92dp.png",
"googleLogo");
var response = await onboardingServiceClient.UploadFromLinkAsync(fileToUpload);
if(response.StatusCode == 200)
{
// Media was onboarded!
// Lets make a datasource to show in the api
var uploadDto = response.Result;
var enties = new List<DynamicEntity>
{
new DynamicEntity
{
Key = uploadDto.Id,
Properties= {
new DynamicProperty { Id= "url", Value = uploadDto.PublicUrl },
new DynamicProperty { Id= "name", Value = uploadDto.MetaData.Filename },
new DynamicProperty { Id= "mimeType", Value = uploadDto.MetaData.MimeType },
new DynamicProperty { Id= "size", Value = uploadDto.MetaData.Size.ToString() }
}
},
};
var response = await onboardingServiceClient.StartEntityImportAsync(dataSource, enties);
if(response.StatusCode == 202)
{
// Data was onboarded!
}
}
}