public async Task <List <User> > PostUsersForListOfUserID(List <int> UserIDs) { List <User> result = new List <User>(); string path = $"/api/PostUsersForListOfUserID"; string absolutePath = $"{path}"; PostUsersForListOfUserIDRequest postUsersForListOfUserIDRequest = new PostUsersForListOfUserIDRequest() { ListUserID = new ListUserID() { UserIDs = UserIDs } }; string json = JsonConvert.SerializeObject(postUsersForListOfUserIDRequest, Formatting.Indented); var httpContent = new StringContent(json); using (HttpResponseMessage response = await _httpClientWrapper.PostAsync(HttpClientConfigName.UserService, path, httpContent, CancellationToken.None).ConfigureAwait(false)) { string jsonResponse = await response.Content.ReadAsStringAsync(); var postUsersForListOfUserIDResponse = JsonConvert.DeserializeObject <ResponseWrapper <PostUsersForListOfUserIDResponse, UserServiceErrorCode> >(jsonResponse); if (postUsersForListOfUserIDResponse.HasContent && postUsersForListOfUserIDResponse.IsSuccessful) { return(postUsersForListOfUserIDResponse.Content.Users); } else { throw new System.Exception(postUsersForListOfUserIDResponse.Errors.ToString()); } } }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] [RequestBodyType(typeof(PostUsersForListOfUserIDRequest), "Post Users For List Of UserID")] PostUsersForListOfUserIDRequest req, ILogger log) { try { NewRelic.Api.Agent.NewRelic.SetTransactionName("UserService", "PostUsersForListOfUserID"); log.LogInformation("C# HTTP trigger function processed a request."); PostUsersForListOfUserIDResponse response = await _mediator.Send(req); return(new OkObjectResult(ResponseWrapper <PostUsersForListOfUserIDResponse, UserServiceErrorCode> .CreateSuccessfulResponse(response))); } catch (Exception exc) { LogError.Log(log, exc, req); return(new ObjectResult(ResponseWrapper <PostUsersForListOfUserIDResponse, UserServiceErrorCode> .CreateUnsuccessfulResponse(UserServiceErrorCode.UnhandledError, "Internal Error")) { StatusCode = StatusCodes.Status500InternalServerError }); } }