When getting information about a social conversation, like Facebook using the https://api.{{environment}}/api/v2/conversations/messages/:conversationId API, the response contains participants[*].message[*].media[*].url field pointing to an image.
I am trying to download it using HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofInputStream()) where request contains an "Authorization" header format("Basic %s", Base64.getEncoder().encodeToString(format("%s:%s", clientId, clientSecret).getBytes(StandardCharsets.UTF_8))).
The returned response has status code of 303, the returned uri is the same as in request.
Is there some description on how can I download them?
With these urls/endpoints (/api/v2/downloads), the download of a file is a two step process.
Get a Download URL (Temporary) from the Media URL
You will need to request a downloadUrl first (using the media url, and a Genesys Cloud Authorization Bearer token - this is NOT with Basic Auth).
On success, by default, Genesys Cloud sends a 303 (Redirect) with Location Response Header containing the url to redirect to and to get the file from.
You can prevent the 303 Redirect adding issueRedirect=false as a query parameter of your GET request.
The url you get is to access the file on a Genesys Cloud repository (AWS S3). The url contains a temporary security/access token to access the file.
Download the file from the download url: GET {the download url}
YOU MUST NOT SET/SEND AN AUTHORIZATION HEADER ON THIS HTTP REQUEST.
The security token (temporary) is sent as a query parameter (defined in the download url).