I have been unable to find how to pass/post parameters for an enterprise API.
This is the example from documenation in C#:
string json = string.Empty;using ( HttpClient client = new HttpClient() ){ string object= "UserNames"; string method = "methodname"; string requestUrl = $"http://server/service/object/invoke/{object}?method={method}"; // provide token in the Authorization header client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization","b/authorizationkey" ); string[] parameters = new[] { "sa", "", "", "", "" }; // pass the array of parameters as the request data string contentStr = JsonConvert.SerializeObject( parameters ); // send the post request HttpResponseMessage response = client.PostAsync( requestUrl.ToString(), new StringContent( contentStr, Encoding.UTF8, "application/json" ) ).Result; using ( HttpContent content = response.Content ) { Task<string> result = content.ReadAsStringAsync(); json = result.Result; }}
I've been using 'requests' package successfully for getting information from the api but am at a roadblock when trying to find an equivalent way to PostAsync.
Also, I know this isn't a great post, but I need to start a post somewhere to start to be able to upvote or downvote things here.