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.
Hi Baranisudha,
A couple of things to clarify that might help narrow this down:
– Are awsdmat501a and awsdmat601a part of the same DMS, or are they configured as agents in different DMS environments?
– If they belong to different DMS setups, then the token must be defined separately per DMS, and a token from one will not work in the other.
If they are part of the same DMS:
– Are you invoking the exact same endpoint in both cases (e.g., /custom/data/parameter/)?
– If the endpoints differ, make sure the token is correctly configured and linked to each specific User-Defined API endpoint involved.
– Since you mentioned using PutAsync, I just want to confirm that the request is indeed targeting the same endpoint in both clusters.
If both agents are within the same DMS and you are using the same endpoint and token, but the issue persists on awsdmat601a, I would recommend reaching out to support@dataminer.services for further investigation, as this may indicate an environment-specific configuration issue.
Token is correctly passed. This same PutAsync is working with different cluster (awsdmat501a). Im not getting 401 error in that DM cluster. I can see the element is created with the payload data i have sent through postman. Im not sure whats missing in awsdmat601a cluster