Using DataAPI im trying to create an element.
Im using the existing skyline repo as reference for this - SLC-UDAPI-DataAPI-Proxy
Below is the api call code and also im adding the screenshot of error im getting.
private static (HttpStatusCode statusCode, string response) PushDataToLocalApi(string url, Dictionary<string, string> headers, string body, IEngine engine)
{
var content = new StringContent(body, Encoding.UTF8, "application/json");
foreach (var header in headers)
{
engine.GenerateInformation($"Header Key [{header.Key}");
engine.GenerateInformation($"Header Value [{header.Value}");
content.Headers.Add(header.Key, header.Value);
}
var result = sharedClient.PutAsync(url, content).Result;
string responseBody = result.Content.ReadAsStringAsync().Result;
engine.GenerateInformation($"Data API Response [{result.StatusCode}]: {responseBody}");
engine.GenerateInformation($"Request URL: {sharedClient.BaseAddress}{url}");
return (result.StatusCode, responseBody);
}

Im getting 401 error, but PutAsync is not accepting any token. Can anyone help me resolve this?
Hi Baranisudha Murugesan,
While the code does not need to handle a token, this must be configured in the User-Defined APIs in the system center.
For each custom endpoint you will need at least one token configured. See: Defining a new API | DataMiner Docs
Most likely, the token you have is not correct or it is not correctly linked to the UDAPI for creating elements.