Wie konvertieren Sie eine HTTP-Antwort mit Inhaltstypanwendung/JSON in Anwendung/Oktettstrom?Java

Java-Forum
Anonymous
 Wie konvertieren Sie eine HTTP-Antwort mit Inhaltstypanwendung/JSON in Anwendung/Oktettstrom?

Post by Anonymous »

Was ist das Problem? Zeit. < /li>
[*] Die Integrationsanforderung des Standards von API -Gateway -Verwendungsanforderungen von Standardakzeption < /> ist

Code: Select all

APPLICATION/JSON
.
[*] S3 antwortet also mit dem Inhaltstyp : application/json Header. Der Inhalt ist jedoch von Typ Anwendung/Oktett-Stream .
Zur Deserialisierung des Inhalts, den ich auf Java.util.zip.zipexception begegnen: Falsch Header-Check Fehler aufgrund von Content-Typ Mismatch. class = "Lang-Java PrettyPrint-Override">

Code: Select all

    String apiUrl = "https://url";

//REQUEST
final var client = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(apiUrl);
httpGet.addHeader("Accept", "application/octet-stream"); //IT IS USELESS TO ADD HERE (IGNORED).

//RESPONSE
var response = client.execute(httpGet);

//DESERIALIZATION
byte[] responseString = EntityUtils.toByteArray(response.getEntity());

CustomObject fullValuationObject = CompressedReadWriteFormat.deserializeDeflated(responseString);
Was habe ich bereits ausprobiert? Wir möchten jedoch kein weiteres API -Gateway für dasselbe erstellen.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post