@@ -5,27 +5,23 @@ import * as ProfileApi from "azure-devops-node-api/ProfileApi";
55import * as ProfileInterfaces from "azure-devops-node-api/interfaces/ProfileInterfaces" ;
66
77export async function run ( projectId : string ) {
8- const webApi : nodeApi . WebApi = await common . getWebApi ( ) ;
8+ let serverUrl = process . env [ "API_URL" ] ;
9+ // Profile api can't be hit at the org level, has to be hit at the deployment level, so url should be structured like set API_URL=https://vssps.dev.azure.com/{orgName}
10+ serverUrl = serverUrl . replace ( '://dev.azure.com' , '://vssps.dev.azure.com' ) ;
11+ console . log ( 'serverUrl' , serverUrl ) ;
12+ const webApi : nodeApi . WebApi = await common . getWebApi ( serverUrl ) ;
913 const profileApiObject : ProfileApi . IProfileApi = await webApi . getProfileApi ( ) ;
1014 common . banner ( "Profile Samples" ) ;
1115
1216 common . heading ( "Create a profile" ) ;
1317 const createProfileContext : ProfileInterfaces . CreateProfileContext = { cIData : null ,
1418 contactWithOffers : false ,
1519 countryName : "US" ,
16- displayName : null ,
20+ displayName : "displayedName" ,
1721 emailAddress : "sample@microsoft.com" ,
1822 hasAccount : false ,
1923 language : "english" ,
2024 phoneNumber : "123456890" } ;
2125 let profile : ProfileInterfaces . Profile = await profileApiObject . createProfile ( createProfileContext , false ) ;
2226 console . log ( "Profile created for" , profile . coreAttributes . DisplayName . value ) ;
23-
24- common . heading ( "Get the avatar" ) ;
25- const avatar : ProfileInterfaces . Avatar = await profileApiObject . getAvatar ( profile . id ) ;
26- console . log ( "Avatar value:" , avatar . value ) ;
27-
28- common . heading ( "Get region information" ) ;
29- const regions : ProfileInterfaces . ProfileRegions = await profileApiObject . getRegions ( ) ;
30- console . log ( `There are ${ regions . regions . length } regions found including regions like ${ regions . regions [ 0 ] . name } ` ) ;
3127}
0 commit comments