diff --git a/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/polling/PollOperation.java b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/polling/PollOperation.java index f2a4bf6e7281..e993e1451f67 100644 --- a/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/polling/PollOperation.java +++ b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/polling/PollOperation.java @@ -120,7 +120,7 @@ public static Function>, Mono> fetchResul U result = deserialize(serializerAdapter, value, finalResultType); return result != null ? Mono.just(result) : Mono.empty(); } else { - return pipeline.send(new HttpRequest(HttpMethod.GET, finalResult.getResultUri())) + return pipeline.send(decorateRequest(new HttpRequest(HttpMethod.GET, finalResult.getResultUri()))) .flatMap((Function>) response -> response.getBodyAsString()) .flatMap(body -> { U result = deserialize(serializerAdapter, body, finalResultType); @@ -173,7 +173,7 @@ private static Mono>> pollResponseMono(Serializer * @return a Mono emitting PollingState updated from the poll operation response */ private static Mono doSinglePoll(HttpPipeline pipeline, PollingState pollingState) { - return pipeline.send(new HttpRequest(HttpMethod.GET, pollingState.getPollUrl())) + return pipeline.send(decorateRequest(new HttpRequest(HttpMethod.GET, pollingState.getPollUrl()))) .flatMap((Function>) response -> response.getBodyAsString() .map(body -> pollingState.update(response.getStatusCode(), response.getHeaders(), body)) .switchIfEmpty(Mono.defer(() -> { @@ -183,6 +183,16 @@ private static Mono doSinglePoll(HttpPipeline pipeline, PollingSta }))); } + /** + * Decorate the request. + * + * @param httpRequest the HttpRequest + * @return the HttpRequest with decoration. + */ + private static HttpRequest decorateRequest(HttpRequest httpRequest) { + return httpRequest.setHeader("Accept", "application/json"); + } + /** * Decode a string value. *