From 9b19950945cff02945c2d5e0237db8c74cceb7a1 Mon Sep 17 00:00:00 2001 From: Peter Bastiani Date: Mon, 4 Mar 2024 13:20:23 +0100 Subject: [PATCH] Fix upload json formatting Fix extraAttributes null exception --- projects/common/src/fm/services/item.service.ts | 2 +- projects/common/src/fm/services/itemtype.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/common/src/fm/services/item.service.ts b/projects/common/src/fm/services/item.service.ts index 63d5355..c302639 100644 --- a/projects/common/src/fm/services/item.service.ts +++ b/projects/common/src/fm/services/item.service.ts @@ -154,7 +154,7 @@ export class ItemService { putItemFile(item: IItem, jsonObject: any): Observable { const formData = new FormData(); - const file = new File([JSON.stringify(jsonObject)], 'data.dat', {type: 'application/json'}); + const file = new File([JSON.stringify(jsonObject, undefined, '\t')], 'data.dat', {type: 'application/json'}); formData.append('file', file); return this.httpClient.put(`${this.ApiEndpoint()}/api/v1/items/${item.code}/data`, formData); } diff --git a/projects/common/src/fm/services/itemtype.service.ts b/projects/common/src/fm/services/itemtype.service.ts index cc06612..6887532 100644 --- a/projects/common/src/fm/services/itemtype.service.ts +++ b/projects/common/src/fm/services/itemtype.service.ts @@ -27,7 +27,7 @@ export class ItemTypeService { getExtraAttributes(itemType: string) { let extraAttributes = null; - if (this.itemTypes[itemType]) extraAttributes = this.itemTypes[itemType].extraAttributes; + if (this.itemTypes[itemType] && this.itemTypes[itemType].extraAttributes) extraAttributes = this.itemTypes[itemType].extraAttributes; return extraAttributes; }