cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
979
Views
0
Helpful
2
Replies

UCCE 11.6 Rest API Bulk Agent C# POSTing

benjaminwilk
Level 1
Level 1

I am attempting to write some scripts in C# that will take advantage of the UCCE 11.6 Rest API.  In particular, I am looking to do bulk agent creation.

 

I am able to successfully connect to the remote server where UCCE lives, but when I try to send a POST command with a payload, I get a "Method not Allowed".  I'm assuming my payload is not formatted correctly; what is the proper formatting for the payload?

 

RestClient client = new RestClient("http://xxx.xxx.xxx.xxx/unifiedconfig/config/");
client.Authenticator = new HttpBasicAuthenticator("user@user.local", "passwd");
var request = new RestRequest("bulkjob/create", Method.POST);

string xmlPayload = "<create><agentId>999999</agentId><firstName>Johnny</firstName><lastName>Testuser</lastName><userName>john9999</userName><loginEnabled>true</loginEnabled><ssoEnabled>true</ssoEnabled></create>";

request.AddParameter("application/xml; charset=utf-8", xmlPayload, ParameterType.RequestBody);
request.RequestFormat = RestSharp.DataFormat.Json;

var response = client.Execute(request);
agentCreationText.AppendText("\nResponse Status: " + response.StatusCode.ToString());

 

2 Replies 2

Sasikumar Divvela
Cisco Employee
Cisco Employee

can you remove /create from this and try once. 

var request = new RestRequest("bulkjob/create", Method.POST);

 

Removed the "/create" from after the bulkjob.  I now receive "BadRequest".  I'm assuming my payload is not formatted correctly.  Is there a portion of the API guide in regards to how to format the payload?