contentstack.management.csharp
0.1.7
See the version list below for details.
dotnet add package contentstack.management.csharp --version 0.1.7
NuGet\Install-Package contentstack.management.csharp -Version 0.1.7
<PackageReference Include="contentstack.management.csharp" Version="0.1.7" />
paket add contentstack.management.csharp --version 0.1.7
#r "nuget: contentstack.management.csharp, 0.1.7"
// Install contentstack.management.csharp as a Cake Addin #addin nuget:?package=contentstack.management.csharp&version=0.1.7 // Install contentstack.management.csharp as a Cake Tool #tool nuget:?package=contentstack.management.csharp&version=0.1.7
Contentstack Management .NET SDK
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. All you have to do is build your application frontend, and Contentstack will take care of the rest. Read More.
This SDK uses the Content Management API (CMA). The CMA is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account. To use the CMA, you will need to authenticate your users with a Management Token or an Authtoken. Read more about it in Authentication.
Note: By using CMA, you can execute GET requests for fetching content. However, we strongly recommend that you always use the Content Delivery API to deliver content to your web or mobile properties.
Prerequisite
You need .NET installed on your machine to use the Contentstack .NET CMA SDK.
Installation
Open the terminal and install the contentstack module via ‘Package Manager’ command
PM> Install-Package Contentstack.Management.Core
And via ‘.Net CLI’
dotnet add package Contentstack.Management.Core
To use the module in your application, you need to first Add Namespace to your class
using Contentstack.Management.Core; // ContentstackClient, ContentstackClientOptions, ContentstackResponse
using Contentstack.Management.Core.Models; // Stack, ContentType, Entry, Asset
Authentication
To use this SDK, you need to authenticate your users by using the Authtoken, credentials, or Management Token (stack-level token).
Authtoken
An Authtoken is a read-write token used to make authorized CMA requests, and it is a user-specific token.
var options = new ContentstackOptions()
{
Host = "<API_HOST>",
Authtoken = "<AUTHTOKEN>"
}
ContentstackClient client = new ContentstackClient(new OptionsWrapper<ContentstackClientOptions>(options));
Login
To Login to Contentstack by using credentials, you can use the following lines of code:
ContentstackClient client = new ContentstackClient();
NetworkCredential credentials = new NetworkCredential("<EMAIL>", "<PASSWORD>");
// Sync call
ContentstackResponse contentstackResponse = client.Login(credentials);
// Async call
client.LoginAsync(credentials).ContinueWith((t) => {
if (t.IsCompleted && t.Status != System.Threading.Tasks.TaskStatus.Faulted)
{
// success
}
});
Management Token
Management Tokens are stack-level tokens, with no users attached to them.
Stack stack = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>");
Contentstack Management .NET SDK: 5-minute Quickstart
Initializing Your SDK:
To use the .Net CMA SDK, you need to first initialize it. To do this, use the following code:
using Contentstack.Management.Core;
var options = new ContentstackOptions()
{
Host = "<API_HOST>",
Authtoken = "<AUTHTOKEN>"
}
ContentstackClient client = new ContentstackClient(new OptionsWrapper<ContentstackClientOptions>(options));
For Setting the branch:
If you want to initialize the SDK in a particular branch, use the following code:
using Contentstack.Management.Core
ContentstackClient client = new ContentstackClient();
client.Stack("API_KEY", "MANAGEMENT_TOKEN", "BRANCH");
Proxy Configuration
Contentstack allows you to define HTTP proxy for your requests with the .NET Management SDK. A proxied request allows you to anonymously access public URLs even from within a corporate firewall through a proxy server.
Here is the basic syntax of the proxy settings that you can pass within fetchOptions of the .NET Management SDK:
using System.Net;
var contentstackConfig = new ContentstackClientOptions();
contentstackConfig.ProxyHost = "http://127.0.0.1";
contentstackConfig.ProxyPort = 9000;
contentstackConfig.ProxyCredentials = new NetworkCredential(userName: "username", password: "password");
ContentstackClient client = new ContentstackClient(new OptionsWrapper<ContentstackClientOptions>(options));
Fetch Stack Detail
Use the following lines of code to fetch your stack detail using this SDK:
ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Fetch();
var response = contentstackResponse.OpenJObjectResponse();
// or
StackResponse model = contentstackResponse.OpenTResponse<StackResponse>();
Create an Entry
You can use the following code to create an entry in a specific content type of a stack through the SDK:
EntryModel entry = new EntryModel() {
Title: "Sample Entry",
Url: "/sampleEntry"
}
ContentstackClient client = new ContentstackClient();
Stack stack = client.Stack("API_KEY");
ContentstackResponse contentstackResponse = stack.ContentType("CONTENT_TYPE_UID").Entry().Create(entry);
Upload Assets
Use the following code snippet to upload assets to your stack through the SDK:
ContentstackClient client = new ContentstackClient();
Stack stack = client.Stack("API_KEY");
var path = Path.Combine(Environment.CurrentDirectory, "path/to/file");
AssetModel asset = new AssetModel("Asset Title", path, "application/json");
ContentstackResponse response = stack.Asset().Create(asset);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 is compatible. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.1
- Microsoft.Extensions.Options (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.2)
- System.Net.Http (>= 4.3.4)
-
.NETFramework 4.7.2
- Microsoft.Extensions.Options (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.2)
- System.Net.Http (>= 4.3.4)
-
.NETStandard 2.0
- Microsoft.Extensions.Options (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.2)
- System.Net.Http (>= 4.3.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on contentstack.management.csharp:
Package | Downloads |
---|---|
contentstack.management.aspnetcore
.NET SDK for the Contentstack Content Management API. |
GitHub repositories
This package is not used by any popular GitHub repositories.
ContentType query issue resolved