Splunk Enterprise

Splunk REST API Post route is throwing Cannot perform action "POST" without a target name to act on .net core

mylarehman
New Member

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; }

}

Labels (2)
0 Karma

mylarehman
New Member

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?

0 Karma

damode1
Path Finder

hi, I am facing same issue. did you end up fixing it?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...