09-23-2019 08:11 AM
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());
09-23-2019 09:08 AM
can you remove /create from this and try once.
var request = new RestRequest("bulkjob/create", Method.POST);
09-24-2019 07:50 AM
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?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide