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
Get Updates on the Splunk Community!

Routing Data to Different Splunk Indexes in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...

Getting Started with AIOps: Event Correlation Basics and Alert Storm Detection in ...

Getting Started with AIOps:Event Correlation Basics and Alert Storm Detection in Splunk IT Service ...

Register to Attend BSides SPL 2022 - It's all Happening October 18!

Join like-minded individuals for technical sessions on everything Splunk!  This is a community-led and run ...