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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...