diff --git a/system/Tnb.Systems/System/DataInterfaceService.cs b/system/Tnb.Systems/System/DataInterfaceService.cs index 9ca5c55b..15af8000 100644 --- a/system/Tnb.Systems/System/DataInterfaceService.cs +++ b/system/Tnb.Systems/System/DataInterfaceService.cs @@ -326,11 +326,11 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController } VerifyRequired(info, dicParameters); ReplaceParameterValue(info, dicParameters); - if (info.DataType == 1) + if (info?.DataType == 1) { output = await GetData(info); } - else if (info.DataType == 2) + else if (info?.DataType == 2) { output = info.Query.ToObject(); } @@ -338,7 +338,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController { output = await GetApiDataByTypePreview(info); } - if (info.DataProcessing.IsNullOrEmpty()) + if (info is null || info.DataProcessing.IsNullOrEmpty()) { return output; } @@ -897,8 +897,8 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController private async Task GetApiDataByTypePreview(DataInterfaceEntity entity) { var result = new JObject(); - var parameters = entity.RequestParameters.ToObject>(); - var parametersHerader = entity.RequestHeaders.ToObject>(); + var parameters = entity?.RequestParameters.ToObject>() ?? new List(); + var parametersHerader = entity?.RequestHeaders.ToObject>() ?? new List(); var dic = new Dictionary(); var dicHerader = new Dictionary(); dicHerader.Add("JNPF_API", true); @@ -914,7 +914,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController dicHerader[key.field] = key.defaultValue; } - switch (entity.RequestMethod) + switch (entity?.RequestMethod) { case "6": result = (await entity.Path.SetHeaders(dicHerader).SetQueries(dic).GetAsStringAsync()).ToObject();