Forum Discussion
LocalStorage V2 always returning as undefined
- 11 months ago
Hi hugofernandes,
I replicated your setup using a new visual, and it looks fine in terms of how you're trying to access the API, but I had the same issues as you. This is weird, as I have built visuals for people using this API, so I know it works, but I dug further and found what is hopefully the same root cause as will be for you.
Check your pbiviz.json, under apiVersion. If you've set up a brand new visual using the tools and haven't changed this, the tools set this to 5.3.0 by default, e.g.:
{ "visual": { "name": "storageTest", "displayName": "storageTest", "guid": "storageTestD056CAC136254AB789825C03790B59FA", "visualClassName": "Visual", "version": "1.0.0.0", "description": "", "supportUrl": "", "gitHubUrl": "" }, "apiVersion": "5.3.0", // <------ THIS RIGHT HERE "author": { "name": "", "email": "" }, "assets": { "icon": "assets/icon.png" }, "externalJS": null, "style": "style/visual.less", "capabilities": "capabilities.json", "dependencies": null, "stringResources": [], "version": "1.0.0.0" }If you try to access the V2 local storage API with this version, it will return as undefined, because it wasn't introduced until 5.8.0.
If you set your apiVersion to "5.8.0" or higher (I used 5.9.1), stop your server and re-run the start task, the tools will install the relevant version of powerbi-visuals-api for you, e.g.:
When you re-run this will now show in the console as defined, e.g.:
You should then be able to continue to use as normal.
Good luck!
Daniel
Hey, DataNinja777 ,
If i add the "StorageV2" instead of "LocalStorage" returns the error:
error should be equal to one of the allowed values .privileges[2].name
error Invalid capabilitiesThe error itself was the package version, that was using the 5.3.0 instead of the more recent that has this api implemented.
Thanks for recommending the best practices and sending a base code!
Will adjust my code to follow it!
- Natalie_iTalent11 months agoAdministrator
Hello hugofernandes, the comment you responded to has been removed. I'm glad you were able to find a solution to your question.
Best,
Natalie H.
Community Manager