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!

Security Highlights: September 2022 Newsletter

 September 2022 The Splunk App for Fraud Analytics (SFA) is now Splunk SupportedUse your existing Splunk ...

Platform Highlights | September 2022 Newsletter

 September 2022 What’s New in 9.0 and How to UpgradeGet a walk through of what is new Splunk Enterprise 9.0 ...

Observability Highlights | September 2022 Newsletter

 September 2022 Splunk Observability SuiteAccess to "Classic" SignalFx Interface Will be Removed on Sept 30, ...