skip to Main Content

As of now, I have to get the work items details from azure devops via api as I have to used it in the third party app but this doesn’t seem to work

This is the API Url I tried to get the work items https://dev.azure.com/testOrgzz/test/_apis/wit/workitems/8?api-version=7.2-preview.3

I’m getting this response even though i have access to all the resources

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en-US"> <head><title> Azure DevOps Services | Sign In </title><meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8" /> <link rel="SHORTCUT ICON" href="/favicon.ico"/> <link data-bundlelength="516093" data-bundlename="commoncss" data-highcontrast="/_static/tfs/M235_20240303.1/_cssbundles/HighContrast/vss-bundle-commoncss-vgKIrce5KeykK4FMEhpmn7zyu-3J73Bx2KsJTMmi4ZaI=" data-includedstyles="jQueryUI-Modified;Core;Splitter;PivotView" href="/_static/tfs/M235_20240303.1/_cssbundles/Default/vss-bundle-commoncss-vuiSc9pHdDbcT8LzK_3fJ2kEsn4_fRqmPx_6IdU0oXHc=" rel="stylesheet" /> <link data-bundlelength="117304" data-bundlename="viewcss" data-highcontrast="/_static/tfs/M235_20240303.1/_cssbundles/HighContrast/vss-bundle-viewcss-vuZc8-qj8Ccsk2Id3aYU0dLxPmsvgd6StlyaYitm0xxU=" data-includedstyles="VSS.Controls" href="/_static/tfs/M235_20240303.1/_cssbundles/Default/vss-bundle-viewcss-vZeWfVvRTo2a7DO4ptMBi0cCBa3W_gjANgU36Es8paWQ=" rel="stylesheet" /> <!--UxServices customizations --> <link href="/_static/tfs/M235_20240303.1/_content/Authentication.css" type="text/css" rel="stylesheet" /> </head> <body class="platform"> <script type="text/javascript"> var __vssPageContext = {"webContext":{"user":{"id":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa","name":"Anonymous","email":"","uniqueName":"TEAM FOUNDATION\Anonymous"},"host":{"id":"12151c76-78d9-45df-bc19-5b98a8c97843","name":"TEAM FOUNDATION","uri":"https://spsprodcin2.vssps.visualstudio.com/","relativeUri":"/","hostType":"deployment","scheme":"https","authority":"spsprodcin2.vssps.visualstudio.com"}},"moduleLoaderConfig":{"baseUrl":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/","paths":{"UserManagement/Scripts/Resources":"en-US","Authentication/Scripts/Resources":"en-US","Profile/Scripts/Resources":"en-US","VSS/Resources":"en-US","Account/Scripts/Resources":"en-US"},"map":{},"contributionPaths":{"VSS":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/VSS","pathType":"default"},"VSS/Resources":{"value":"en-US","pathType":"resource"},"q":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/q","pathType":"default"},"knockout":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/knockout","pathType":"default"},"mousetrap":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/mousetrap","pathType":"default"},"mustache":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/mustache","pathType":"default"},"react":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/react.15.3","pathType":"default"},"react-dom":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/react-dom.15.3","pathType":"default"},"react-transition-group":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/react-transition-group.15.3","pathType":"default"},"jQueryUI":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/jQueryUI","pathType":"default"},"jquery":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/jquery","pathType":"default"},"OfficeFabric":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/OfficeFabric","pathType":"default"},"tslib":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/tslib","pathType":"default"},"@uifabric":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/@uifabric","pathType":"default"},"VSSUI":{"value":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/VSSUI","pathType":"default"}},"shim":{"jquery":{"deps":[],"exports":"jQuery"}},"waitSeconds":30},"coreReferences":{"stylesheets":[{"url":"/_static/tfs/M235_20240303.1/_cssbundles/Default/vss-bundle-ext-core-css-vdl6C9oqaY8jIYGt0fSVzQfhTlc3U3sLKE8T0mcZwW_0=","highContrastUrl":null,"isCoreStylesheet":true}],"scripts":[{"identifier":"JQuery","url":"/_static/3rdParty/_scripts/jquery-3.6.0.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"JQueryXDomain","url":"/_static/3rdParty/_scripts/jquery.xdomainrequest.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"Promise","url":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/promise.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"GlobalScripts","url":"/_static/tfs/M235_20240303.1/_scripts/TFS/min/global-scripts.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"LoaderFixes","url":"/_static/tfs/M235_20240303.1/_scripts/TFS/pre-loader-shim.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":false},{"identifier":"AMDLoader","url":"/_static/3rdParty/_scripts/require.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"LoaderFixes","url":"/_static/tfs/M235_20240303.1/_scripts/TFS/post-loader-shim.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":false}],"coreScriptsBundle":{"identifier":"CoreBundle","url":"/_public/_Bundling/Content?bundle=vss-bundle-basejs-vx38JYf0FTtFkI9k88H54KYCLs9sIP_6xJwgWGnd-xvw=","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},"extensionCoreReferences":{"identifier":"CoreBundle","url":"/_public/_Bundling/Content?bundle=vss-bundle-ext-core-vjCrGJd2ZXxlGKsVv7B3hWY-FuFMmxCW3Tcq4LWjQhfc=","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true}},"webAccessConfiguration":{"isHosted":true,"paths":{"rootPath":"/","staticContentRootPath":"/","staticContentVersion":"M235_20240303.1","resourcesPath":"/_static/tfs/M235_20240303.1/_content/","staticRootTfs":"/_static/tfs/M235_20240303.1/","cdnFallbackStaticRootTfs":"/_static/tfs/M235_20240303.1/","staticRoot3rdParty":"/_static/3rdParty/"},"api":{"webApiVersion":"1","areaPrefix":"_","controllerPrefix":""},"mailSettings":{"enabled":false},"registryItems":{}},"microsoftAjaxConfig":{"cultureInfo":{"name":"en-US","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":".","IsReadOnly":true,"CurrencyGroupSizes":[3],"NumberGroupSizes":[3],"PercentGroupSizes":[3],"CurrencyGroupSeparator":",","CurrencySymbol":"$","NaNSymbol":"NaN","CurrencyNegativePattern":0,"NumberNegativePattern":1,"PercentPositivePattern":1,"PercentNegativePattern":1,"NegativeInfinitySymbol":"-∞","NegativeSign":"-","NumberDecimalDigits":2,"NumberDecimalSeparator":".","NumberGroupSeparator":",","CurrencyPositivePattern":0,"PositiveInfinitySymbol":"∞","PositiveSign":"+","PercentDecimalDigits":2,"PercentDecimalSeparator":".","PercentGroupSeparator":",","PercentSymbol":"%","PerMilleSymbol":"‰","NativeDigits":["0","1","2","3","4","5","6","7","8","9"],"DigitSubstitution":1},"dateTimeFormat":{"AMDesignator":"AM","Calendar":{"MinSupportedDateTime":"0001-01-01T00:00:00","MaxSupportedDateTime":"9999-12-31T23:59:59.9999999","AlgorithmType":1,"CalendarType":1,"Eras":[1],"TwoDigitYearMax":2049,"IsReadOnly":true},"DateSeparator":"/","FirstDayOfWeek":0,"CalendarWeekRule":0,"FullDateTimePattern":"dddd, MMMM d, yyyy h:mm:ss tt","LongDatePattern":"dddd, MMMM d, yyyy","LongTimePattern":"h:mm:ss tt","MonthDayPattern":"MMMM d","PMDesignator":"PM","RFC1123Pattern":"ddd, dd MMM yyyy HH':'mm':'ss 'GMT'","ShortDatePattern":"M/d/yyyy","ShortTimePattern":"h:mm tt","SortableDateTimePattern":"yyyy'-'MM'-'dd'T'HH':'mm':'ss","TimeSeparator":":","UniversalSortableDateTimePattern":"yyyy'-'MM'-'dd HH':'mm':'ss'Z'","YearMonthPattern":"MMMM yyyy","AbbreviatedDayNames":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"ShortestDayNames":["Su","Mo","Tu","We","Th","Fr","Sa"],"DayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"AbbreviatedMonthNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthNames":["January","February","March","April","May","June","July","August","September","October","November","December",""],"IsReadOnly":true,"NativeCalendarName":"Gregorian Calendar","AbbreviatedMonthGenitiveNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthGenitiveNames":["January","February","March","April","May","June","July","August","September","October","November","December",""]},"numberShortForm":{"QuantitySymbols":["K","M","B"],"NumberGroupSize":1000,"ThousandSymbol":"K"},"eras":null}},"timeZonesConfiguration":{},"featureAvailability":{"featureStates":{"VisualStudio.Services.Contribution.EnableOnPremUnsecureBrowsers":false,"VisualStudio.Service.WebPlatform.ClientErrorReporting":false,"Microsoft.VisualStudio.Services.Gallery.Client.UseCdnAssetUri":false,"VisualStudio.Services.WebAccess.SubresourceIntegrity":false,"VisualStudio.Services.IdentityPicker.ReactProfileCard":true}},"appInsightsConfiguration":{"enabled":false,"instrumentationKey":"00000000-0000-0000-0000-000000000000","insightsScriptUrl":null},"diagnostics":{"sessionId":"c3346a50-2005-48c7-ab99-14f9bb4d09a1","activityId":"c3346a50-2005-48c7-ab99-14f9bb4d09a1","bundlingEnabled":true,"webPlatformVersion":"M235","serviceVersion":"Dev19.M235.1 (build: AzureDevOps_M235_20240303.1)"},"navigation":{"topMostLevel":"deployment","area":"","currentController":"Signin","currentAction":"Index","routeId":"LegacyWebAccessRoute","routeValues":{"controller":"Signin","action":"Index"}},"globalization":{"explicitTheme":"","theme":"Default","culture":"en-US","timezoneOffset":0,"timeZoneId":"UTC"},"serviceInstanceId":"951917ac-a960-4999-8464-e3f0aa25b381","hubsContext":{},"serviceLocations":{"locations":{"951917ac-a960-4999-8464-e3f0aa25b381":{"Application":"https://spsprodcin2.vssps.visualstudio.com/","Deployment":"https://spsprodcin2.vssps.visualstudio.com/"}}}};</script><script type="text/javascript"> var __cultureInfo = __vssPageContext.microsoftAjaxConfig.cultureInfo;</script> <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('startLoadBundleOuter-basejs'); }</script> <script data-bundlelength="127542" data-bundlename="basejs" src="/_public/_Bundling/Content?bundle=vss-bundle-basejs-vx38JYf0FTtFkI9k88H54KYCLs9sIP_6xJwgWGnd-xvw=" type="text/javascript"></script> <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('endLoadBundleOuter-basejs'); }</script> <script type="text/javascript"> require.config(__vssPageContext.moduleLoaderConfig);</script> <input name="__RequestVerificationToken" type="hidden" value="FJG81vvsBPN1oWz_cBvThEFBMcDuUIWjDXPqE-5Bz_Uv882aOolthNQn8HRkz9NliIO4VoRtOb7wcsrriLaCP7LI5GAlkd5QRqJkTalhoKs1" /><input name="__RequestVerificationToken2" type="hidden" value="__RequestVerificationToken23730970b-0210-41a9-8e66-bda02d908bc1" /> <div class="account signin main-container hide"> <div class="page-content"> <div class="header-section" role="banner"> <link rel="stylesheet" type="text/css" href="/_static/tfs/M235_20240303.1/_content/Combined.css"> <div id="ux-header" class="FF ltr vsIntegrate" xmlns="http://www.w3.org/1999/xhtml"> <span id="isMobile"></span> <div class="upperBand"> <div class="upperBandContent"> <div class="left"></div> <div class="right"> <div class="profileImage"></div> <div id="signIn"> <a class=":SignedOutProfileElement: createProfileLink" href="/go/profile" title="Anonymous">Anonymous</a> <a class="scarabLink" href="/_signout">Sign out</a> </div> </div> <div class="clear-both"></div> </div> </div> </div> </div> <div class="content-section" role="main"> <div class="signin-main-content"> <noscript> <span class="error">Microsoft Internet Explorer's Enhanced Security Configuration is currently enabled on your environment. This enhanced level of security prevents our web integration experiences from displaying or performing correctly. To continue with your operation please disable this configuration or contact your administrator.</span> </noscript> <div class="provider-control"> <script class="options" defer="defer" type="application/json">{"providerOptions":{"force":false,"orgIdAuthUrl":"https://login.microsoftonline.com/528e5402-5360-438b-a03f-6ff3444bd09a/oauth2/authorize?client_id=499b84ac-1321-427f-aa17-267ca6975798u0026site_id=501454u0026response_mode=form_postu0026response_type=code+id_tokenu0026redirect_uri=https%3A%2F%2Fspsprodcin2.vssps.visualstudio.com%2F_signedinu0026nonce=b7ecf939-0b7f-4207-9cca-63369953ab2fu0026state=realm%3Ddev.azure.com%26reply_to%3Dhttps%253A%252F%252Fdev.azure.com%252FtestOrgzz%252Ftest%252F_apis%252Fwit%252Fworkitems%252F8%253Fapi-version%253D7.2-preview.3%26ht%3D2%26hid%3Db368bbd6-b7b0-467a-945f-d7725c374479%26nonce%3Db7ecf939-0b7f-4207-9cca-63369953ab2fu0026resource=https%3A%2F%2Fmanagement.core.windows.net%2Fu0026cid=b7ecf939-0b7f-4207-9cca-63369953ab2fu0026wsucxt=1","user":null,"signInContext":"eyJodCI6MiwiaGlkIjoiN2ZlNDA4NGUtZTg4MS00YjBjLWFkNTUtZmYxOWIwMTg0OTlmIiwicXMiOnsicmVhbG0iOiJkZXYuYXp1cmUuY29tIiwicmVwbHlfdG8iOiJodHRwczovL2Rldi5henVyZS5jb20vdGVzdE9yZ3p6L3Rlc3QvX2FwaXMvd2l0L3dvcmtpdGVtcy84P2FwaS12ZXJzaW9uPTcuMi1wcmV2aWV3LjMiLCJodCI6IjIiLCJoaWQiOiJiMzY4YmJkNi1iN2IwLTQ2N2EtOTQ1Zi1kNzcyNWMzNzQ0NzkiLCJub25jZSI6ImI3ZWNmOTM5LTBiN2YtNDIwNy05Y2NhLTYzMzY5OTUzYWIyZiJ9LCJyciI6IiIsInZoIjoiIiwiY3YiOiIiLCJjcyI6IiJ90"}}</script> </div> </div> </div> </div> <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('startLoadBundleOuter-common'); }</script> <script data-bundlelength="217072" data-bundlename="common" data-includedscripts="VSS/Bundling" src="/_public/_Bundling/Content?bundle=vss-bundle-common-vR29TkV-17-bwSKtFVO6MaURA35MiJY5Zsze5BA4VMXY=" type="text/javascript"></script> <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('endLoadBundleOuter-common'); }</script> <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('startLoadBundleOuter-view'); }</script> <script data-bundlelength="158653" data-bundlename="view" data-includedscripts="Authentication/Scripts/SPS.Authentication.Controls;Authentication/Scripts/SPS.Authentication" src="/_public/_Bundling/Content?bundle=vss-bundle-view-v_jX79q9C-tQaaE-PqtHzcCrvEtl3XJp6y7RcLisV0Do=" type="text/javascript"></script> <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('endLoadBundleOuter-view'); }</script> <script type="text/javascript"> if (window.performance && window.performance.mark) { window.performance.mark('requireStart'); } require(["Authentication/Scripts/SPS.Authentication.Controls","Authentication/Scripts/SPS.Authentication"], function(){ if (window.performance && window.performance.mark) { window.performance.mark('requireEnd'); } window.requiredModulesLoaded=true; }); </script> </body> </html>

Error

2

Answers


  1. In the error message, the user shows as aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa which indicates you are not passing correct token for the api.

    Please double confirm you are able to access the target work item from DevOps website. To avoid mistake, please regenerate the personal access token.

    You can use below script to get the work item details:

    # Define parameters
    $token = "yourPAT"
    $organization = "orgname"
    $workItemID = "498"     # your work item id
    $uri = "https://dev.azure.com/$organization/_apis/wit/workitems/$workItemID"+"?api-version=7.2-preview.3"
    
    echo $uri    # double check the uri.
    
    # Create authorization header
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((":$($token)")))
    $headers = @{Authorization=("Basic $base64AuthInfo")}
    
    # Send request
    $response = Invoke-RestMethod -Uri $uri -Method Get -ContentType "application/json" -Headers $headers | ConvertTo-Json
    
    # Output work item details
    echo $response
    

    Work item details:
    enter image description here

    Login or Signup to reply.
  2. I registered one Azure AD application and granted vso.work permission as below:

    enter image description here

    Now, I generated one bearer token using authorization code flow via Postman like this:

    POST https://login.microsoftonline.com/<temamtId>/oauth2/v2.0/token
    grant_type:authorization_code
    client_id: <appId>
    client_secret: <secret>
    scope:499b84ac-1321-427f-aa17-267ca6975798/.default
    code:code
    redirect_uri: https://jwt.ms
    

    Response:

    enter image description here

    When I used this token to call Azure DevOps API, I got response with work item details successfully:

    GET https://dev.azure.com/demodevOps25/demoproj/_apis/wit/workitems/1?api-version=7.2-preview.3
    

    Response:

    enter image description here

    In your case, the error might occur if third-party application access via OAuth is disabled for your DevOps organization.

    To resolve the error, enable third-party application access via OAuth in your organization like this:

    enter image description here

    Reference:
    Suddenly all Azure DevOps APIs giving 401 error – Microsoft Community Hub by heenachauhan

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search