最近、ナショナル クラウド サポートを追加したアプリケーションで Microsoft Graph API を使用しています。米国の環境では認証は成功しますが、リストの場所の API は、国内のクラウド エンドポイントでは機能していないようです。
private final static String NATIONAL_CLOUD_US_L4="US-L4";
private final static String NATIONAL_CLOUD_US_L5_DOD="US-L5 (DOD)";
private final static String NATIONAL_CLOUD_CHINA="China";
private final static String NATIONAL_CLOUD_GERMANY="Germany";
private final static String GET_ROOMS_GLOBAL = "https://graph.microsoft.com/v1.0/places/microsoft.graph.room?$top=5000";
private final static String GET_ROOMS_US_L4 = "https://graph.microsoft.us/v1.0/places/microsoft.graph.room?$top=5000";
private final static String GET_ROOMS_US_L5_DOD = "https://dod-graph.microsoft.us/v1.0/places/microsoft.graph.room?$top=5000";
private final static String GET_ROOMS_CHINA = "https://microsoftgraph.chinacloudapi.cn/v1.0/places/microsoft.graph.room?$top=5000";
private final static String GET_ROOMS_GERMANY = "https://graph.microsoft.de/v1.0/places/microsoft.graph.room?$top=5000";
private void setNationalCloudUrl(String country) {
switch(country) {
case NATIONAL_CLOUD_US_L4:
GET_ROOMS_URL=GET_ROOMS_US_L4;
break;
case NATIONAL_CLOUD_US_L5_DOD:
GET_ROOMS_URL=GET_ROOMS_US_L5_DOD;
break;
case NATIONAL_CLOUD_GERMANY:
SCOPE = SCOPE_GERMANY;
AUTHORITY_URL=AUTHORITY_URL_GERMANY;
GET_ROOMS_URL=GET_ROOMS_GERMANY;
break;
case NATIONAL_CLOUD_CHINA:
GET_ROOMS_URL=GET_ROOMS_CHINA;
break;
default:
GET_ROOMS_URL=GET_ROOMS_GLOBAL;
break;
}
}
public ResourceProfilesDto retrieveAllResourceProfiles() {
ResourceProfilesDto profilesDto = new ResourceProfilesDto();
List<ResourceProfileDto> profileDtos = new ArrayList<>();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
try {
String accessToken = getAccessToken();
headers.set(AUTHORIZATION, "Bearer " + accessToken);
HttpEntity entity = new HttpEntity(headers);
ResponseEntity<GraphResourceProfileResponse> response = restTemp.exchange(GET_ROOMS_URL, HttpMethod.GET,
entity, GraphResourceProfileResponse.class);
for (GraphResourceProfile graphResource : response.getBody().getValue()) {
ResourceProfileDto resourceProfileDto = new ResourceProfileDto();
resourceProfileDto.setExternalId(graphResource.getEmailAddress());
resourceProfileDto.setHashedExternalId(DigestUtils.sha256Hex(graphResource.getEmailAddress()));
resourceProfileDto.setFriendlyName(graphResource.getDisplayName());
profileDtos.add(resourceProfileDto);
}
profileDtos.sort((p1, p2) -> p1.getFriendlyName().compareTo(p2.getFriendlyName()));
profilesDto.getProfileList().addAll(profileDtos);
}catch(GraphServiceException ex) {
try {
if(ex.getMessage().contains(ACCESS_TOKEN_EXPIRED)) {
configurationService.putSecureString(ACCESS_TOKEN, "");
getAccessToken();
return retrieveAllResourceProfiles();
}
profileDtos = null;
}catch(Exception exception) {
log.error("Exception occurred while retrieveAllResourceProfiles(retry). ERROR is : {}", exception);
profileDtos = null;
}
} catch (Exception e) {
log.error("Error trying to retrieve resource profiles.", e);
profileDtos = null;
}
return profilesDto;
}
org.springframework.web.client.HttpClientErrorException: 400 Bad Request
この行でエラーが発生していますResponseEntity<GraphResourceProfileResponse> response = restTemp.exchange(GET_ROOMS_URL, HttpMethod.GET,entity, GraphResourceProfileResponse.class);
。ただし、これはグローバル エンドポイントでは問題なく機能します。問題は何ですか?