SnipeSharp
SnipeSharp copied to clipboard
Creating license from API
Dear Developer,
please create an update on the project. Especially on the licensemanager. In the license class the category field does not exist but in the snipeit. This will lead to an error if you try to create a license.
Is that possible that you will update all the endpoint models? It would be great.
Thank You: Robi
Unfortunately, I modified SnipeSharp's JsonProperty but couldn't solve this problem. So I implemented it myself using RestSharp and succeeded in creating it.
var client = new RestClient(ApiUrl);
var request = new RestRequest("/licenses", Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddHeader("Accept", "application/json");
request.AddParameter("name", software.DisplayName);
request.AddParameter("seats", 1);
request.AddParameter("category_id", 1);
if(manufacturer != null) {
request.AddParameter("manufacturer_id", manufacturer.Id);
}
if (company != null)
{
request.AddParameter("company_id", company.Id);
}
client.AddDefaultHeader("Authorization", string.Format("Bearer {0}", AccessToken));
client.Execute(request);
https://github.com/gnh1201/SnipeITWindowsAgentPOC