hi,
this often happens due to a timing issue. your code is trying to use the SDK.getService function before the azure devops sdk has fully finished loading on the page.
the fix is to make sure your code runs only after the sdk is completely ready. wrap your service call in the SDK.init() or SDK.ready() function to ensure everything is loaded.
try restructuring your code like this.
import { IExtensionDataService, CommonServiceIds } from "azure-devops-extension-api";
SDK.ready().then(async () => { try { const extDataService = await SDK.getService<IExtensionDataService>(CommonServiceIds.ExtensionDataService); // now u can use extDataService safely } catch (error) { console.error("Failed to get service:", error); } });
this makes sure the sdk is fully initialized before u try to grab the extension data service.
also, check your import statements. make sure you have the correct npm package installed. u need azure-devops-extension-api for those interfaces.
if the problem persists, check the browser's developer console for any other errors about missing resources or failed network requests. sometimes a script might fail to load, breaking the whole sdk.
hope this gets your extension back on track. those data services are super useful once u get them working.
Best regards,
Alex
and "yes" if you would follow me at Q&A - personaly thx.
P.S. If my answer help to you, please Accept my answer