Server returned http response code 400 (Bad Request)

Hello,
I'm trying to download a ContactList, using java.net.HttpURLConnection:

URL url = new URL(exportUri.getUri());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer " + token);

  InputStream in = connection.getInputStream();

The exception thrown is
java.io.IOException: Server returned HTTP response code: 400 for URL: https://prod-euw1-dialer.s3-eu-west-1.amazonaws.com/contact-lists/exports/...

at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)

The thing is, the exact same method works just fine on another server.

Is this some known issue, or do I have to carry on searching for an error on our side ?

Regards

A 400 response means that the client sent an invalid request, so it should be an issue with the way your app is sending the request. Can you provide the correlation ID from the response?

This is the response header:

Key : Transfer-Encoding ,Value : [chunked]
Key : null ,Value : [HTTP/1.1 400 Bad Request]
Key : Server ,Value : [AmazonS3]
Key : Connection ,Value : [close]
Key : x-amz-request-id ,Value : [56EF6FD5ECB34DC8]
Key : x-amz-id-2 ,Value : [sI0ybQJbvZt2sE8lBVI4LtxhfTZzaqEyHo6TUOtIFEoyMUCxhAIOuhR6O70rL26MSiTvSXWXxhU=]
Key : Date ,Value : [Fri, 10 May 2019 06:54:45 GMT]
Key : Content-Type ,Value : [application/xml]

That looks like it may be coming from AWS. Please open a case with PureCloud Care to investigate further.

Hello,

I don't see any correlation id, this is what I get back (I used connection.getHeaderFileds to print all response headers)

---https://api.mypurecloud.ie/api/v2/downloads/72f8ed73
sun.net.www.protocol.https.DelegateHttpsURLConnection:https://api.mypurecloud.ie/api/v2/downloads/72f8ed73
Key : Transfer-Encoding ,Value : [chunked]
Key : null ,Value : [HTTP/1.1 400 Bad Request]
Key : Server ,Value : [AmazonS3]
Key : Connection ,Value : [close]
Key : x-amz-request-id ,Value : [AB984451E14E247B]
Key : x-amz-id-2 ,Value : [TnrUyGc9YO13QTbHa5CN2eaTO1yVydQkDoWKjdEhYqySsIDGEmphoEIizNTEzXoysigmmI1cH4M=]
Key : Date ,Value : [Fri, 10 May 2019 17:45:42 GMT]
Key : Content-Type ,Value : [application/xml]
Download failed: 400
Server returned HTTP response code: 400 for URL: https://prod-euw1-dialer.s3-eu-west-1.amazonaws.com/contact-lists/exports/cf4c21ac-6ff9-417c-a0de-f0f6bc5a9ee5-120_GG_algemeen_mei.csv?response-content-disposition=attachment%3Bfilename%3D"cf4c21ac-6ff9-417c-a0de-f0f6bc5a9ee5-120_GG_algemeen_mei.csv"&X-Amz-Security-Token=REDACTED

But, I accept your reply, I will debug on my side.

There's a difference in Java version between the servers, maybe that's something to look in to.

Thanks for the reponse.

Regards

Will do

Thx

Steven

Careful, that link you posted works fine and I downloaded the CSV successfully. I've edited your post to remove the AWS security token to prevent further leaking of your data.

1 Like

Hello,

I've created a ticket. As a temporary workaround, I take the whole url from the thrown Exception

(https://prod-euw1-dialer.s3-eu-west-1.amazonaws.com/contact-lists/exports/...)

and use this url to download and save the file.

Regards

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.