I am trying to create a role using splunk REST API (https://docs.splunk.com/Documentation/Splunk/8.2.5/RESTREF/RESTaccess#authorization.2Froles). The route works perfectly using postman, but when I try to invoke the same route using IServiceClient via .net core, I run in to "Cannot perform action "POST" without a target name to act on". Please let me know what other information I can provide. Have been searching on google for the error and in splunk documentation with no luck.
using (var client = _serviceClientFactory.GetServiceClient()) //client service factory returns a ServiceClient { PostRoleRequest request = new PostRoleRequest { name = Const.DefaultRoleName //this is the only required param }; var response = await client.PostAsync<PostRoleResponse>($"/services/authorization/roles?output_mode=json", request); } public class PostRoleRequest { public string name { get; set; } }
public class PostRoleResponse
{
public Entry entry { get; set; }
}
public class Entry
{
public string name { get; set; }
public string id { get; set; }
public DateTime updated { get; set; }
public List<string> links { get; set; }
public string author { get; set; }
public Acl acl { get; set; }
public Content content { get; set; }
}
Looks like I have figured what the problem is. If I send a text/html request header format and send the request in text format, the post route works. However, I am really confused as to why the Rest Api doesn't accept json format? Any ideas? What am I missing?
hi, I am facing same issue. did you end up fixing it?