microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions
MIT License
123 stars 38 forks source link

Getting 404 error from SetValue of IExtensionDataManager #25

Closed Y-H-Lai closed 3 years ago

Y-H-Lai commented 4 years ago

Hi, I am not very familiar with Typescript and React yet, but I tried to write an extension hub to be used in Azure DevOps. I wanted to use extension data service to store some data, like users' selection in dropdown.

I read this: https://docs.microsoft.com/en-us/azure/devops/extend/develop/data-storage?view=azure-devops , and tried to work with azure-devops-extension-sdk instead of vss-web-extension-sdk.

I tried to call setValue() as below, although it is not the full code:

public componentDidMount() {
        SDK.init();
        this.initializeComponent(); 
    }

private async initializeComponent() {
        await SDK.ready();
        const extContext = await SDK.getExtensionContext();
        const accessToken = await SDK.getAccessToken();
        const extService = await SDK.getService<IExtensionDataService>(CommonServiceIds.ExtensionDataService);
        const extDataManager = await extService.getExtensionDataManager(extContext.extensionId, accessToken);

        var result = await extDataManager.setValue("testKey","test123", {scopeType: "User"});
}

However, I get this error message:

PUT https://extmgmt.dev.azure.com/{my organisation}/_apis/ExtensionManagement/InstalledExtensions/{my extension}/Data/Scopes/User/Me/Collections/%24settings/Documents 404

My extension was working fine until I added the line of setValue(). I am not sure what causes the error. Hopefully I can get some help with it, thank you!

epignosisx commented 4 years ago

@Y-H-Lai Please see workaround in https://github.com/microsoft/azure-devops-extension-sdk/issues/26. It might help you.

Y-H-Lai commented 4 years ago

@Y-H-Lai Please see workaround in #26. It might help you.

Hey, I had checked out the post, seems like we are having the same error. I will try it out. Thank you for sharing with me!

Y-H-Lai commented 3 years ago

After testing out, the error can be solved as the workaround mentioned by epignosisx.