Asset created via odata API not accessible when @odata.type of Folder ref is set



  • Hi, I am creating a folder with an asset using a java client generated from jsreport's odata metadata. I am currently using jsreport 3.0.0 beta2. I am running into a problem where the asset is visible in the jsreport UI, but it can not be found when I try to access it in javascript, namely using the new localization API; I am creating a "translations" folder with an asset "en.json" in it. If I do this in the UI, everything works normaly. If I create it using the API, it looks the same in the UI, but when I call localize("key", "translations"), I get the error: "localize helper couldn't find asset with data at translations/en.json".

    Debugging this issue, I found the following, and I am not sure whether this is a bug in jsreport or maybe in my client.

    To create the asset, I first create a folder, then get the shortid of the created folder, and then create the asset with a folderRef with that shortid. The generated client sends the FolderRef like this:

    "folder":{"@odata.type":"jsreport.FolderRefType","shortid":"Cry5U0_"}
    

    So when I get the asset via the odata api, the whole object looks like this:

    {
      "name": "en.json",
      "content": "eyJsYW5ndWFnZSI6IkVuZ2xpc2gifQ==",
      "folder": {
        "@odata.type": "jsreport.FolderRefType",
        "shortid": "Cry5U0_"
      },
      "creationDate": "2021-09-07T04:37:24.470Z",
      "modificationDate": "2021-09-07T04:37:24.470Z",
      "shortid": "kJi37GJ",
      "inheritedReadPermissions": [],
      "inheritedEditPermissions": [],
      "_id": "S9Pd9yn3R6Gy97Mi"
    }
    

    However, if I create the same asset with the same content in the UI, it looks almost all the same, just that the folder does not have the "@odata.type" property - and then it works. Seeing that, I modified my generated client code so that it does not send the folder.@odata.type property, and indeed, then it works. Looking ad the odata spec, I think the @odata.type property should actually be included, and I would expect it to work.

    What do you think / am I doing something wrong? Thanks in advance!



  • Thank you for the great description of the problem!
    I can replicate it and work on a fix.



  • Great, thanks. Do you have an issue number so I can track it? Or will you update here?



  • I fixed this so far in the jsreport master branch and it will be part of the next jsreport v3 beta release.
    I'm not sure if we gonna merge it back to the v2.
    However, I noticed, that the problem with the folder after OData post gets resolved after you restart jsreport on its own. Maybe it helps.



  • OK, thanks for the update!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.