Assets not getting picked up on the API call with v2 {#asset} syntax
-
https://drive.google.com/file/d/173DXLexlfGhcUxhR7q82J_OCm2uBGVhi/view?usp=sharing
https://drive.google.com/file/d/1QmwXclxANb1zw8HdLnywVry2KisPjL1v/view?usp=sharingWhen I hit on the API
http://localhost/api/report
with the appropriate payload, It gives me the error shown above but works well in the jsReport editor on the localhost, The API was also working on the older version of the jsReport.Error:
{ "message": "Asset styles.css not found in the store and also not on the disk: Unable to find or read file D:\\js-report\\styles.css. ENOENT: no such file or directory, open 'D:\\js-report\\styles.css'", "stack": "Error: Asset styles.css not found in the store and also not on the disk: Unable to find or read file D:\\js-report\\styles.css. ENOENT: no such file or directory, open 'D:\\js-report\\styles.css'\n at readAsset (D:\\js-report\\node_modules\\@jsreport\\jsreport-assets\\lib\\assetsShared.js:117:15)" }
-
The
styles.css
is just a file or a normal asset entity?
Does the user you use in the API call see it as an entity and has proper permissions for it?
-
I uploaded it to the asset, which can be seen in the asset section in the report studio.
The error disappeared once I disabled the authentication? Which is more strange. (Basically, I created a new config through jsreport init command)
-
Was the user that you used for API call the same you used for the studio preview?
Did you try to run from postman also with the admin user?
-
I created a user from the right tab on the jsreport studio, from the permissions tab. I am assuming it creates a user because without its encrypted header auth, it gave an unauthorized error but when I passed the base64 encrypted string in the header. It gave me the above-mentioned error. I didn't try from the admin user though.
My question here is, is this kind of error supposed to come on authentication issues, it seems a bit misleading.
-
My question here is, is this kind of error supposed to come on authentication issues, it seems a bit misleading.
Yes, you get this error also when the asset isn't found because of the permissions/authorization. The error could be probably improved. We will give it some thought. Sorry for the confusion.
-
Ah, no need to apologize! I really appreciate you guys! You respond fast and are very helpful. Thank you so much.
Btw, so creating a user from the studio should still work right?
I will try a few things and let you know if I get the same error on different users.
-
Yes, you can create a user in the studio, you just need to give him permissions so he can see the assets and other entities he wants to use.
https://jsreport.net/learn/authorizationYou can also login with the custom user to the studio, and verify the permissions are correct.