public async Task <MethodResponse> HandleSaveOpcPublishedConfigurationAsJson(MethodRequest methodRequest, object userContext) { const string logPrefix = "HandleGetOpcPublishedConfigurationAsJson:"; var statusCode = HttpStatusCode.OK; SaveOpcPublishedConfigurationMethodResponseModel saveOpcPublishedConfigurationMethodResponseModel = new SaveOpcPublishedConfigurationMethodResponseModel(); var methodRequestData = JsonConvert.DeserializeObject <HandleSaveOpcPublishedConfigurationMethodRequestModel>(methodRequest.DataAsJson); var success = await NodeConfiguration.SaveJsonAsPublisherNodeConfiguration(methodRequestData.ConfigurationJsonString); NodeConfiguration = new PublisherNodeConfiguration(); //await NodeConfiguration.UpdateNodeConfigurationFileAsync().ConfigureAwait(false); if (!success) { Logger.Information($"{logPrefix} the configuration file is not valid."); statusCode = HttpStatusCode.BadRequest; } saveOpcPublishedConfigurationMethodResponseModel.Success = success; byte[] result = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(saveOpcPublishedConfigurationMethodResponseModel)); if (result.Length > MaxResponsePayloadLength) { Logger.Error($"{logPrefix} Response size is too long"); Array.Resize(ref result, result.Length > MaxResponsePayloadLength ? MaxResponsePayloadLength : result.Length); } MethodResponse methodResponse = new MethodResponse(result, (int)statusCode); Logger.Information($"{logPrefix} completed with result {statusCode.ToString()}"); return(methodResponse); }