Questions tagged [httpurlconnection]
HttpURLConnection instance is used to make a single request but the underlying network connection to the HTTP server may be transparently shared by other instances.
3,224
questions
1
vote
0
answers
32
views
How do I get a Cookie with an invalid character (colon ":") in the cookie name in Java?
First of all, I can't change the cookie name. I would encode it if I had control over it. I don't know how they could add a cookie with invalid chars in the first place.
I'm hitting this endpoint say ...
0
votes
0
answers
29
views
Jlinked jre built from modules in corretto 11 jdk result in "Connection Reset" when attempting HttpUrlConnection
This might be a bug for corretto 11. But before i file one of those i'm hoping someone can peer review my findings. Downloading the most recent corretto 11 jdk for windows: https://corretto.aws/...
0
votes
0
answers
27
views
Why is there java.io.FileNotFoundException when I use HttpURLConnection to get data via api?
Please help ~
There is DailyForeignExchangeRates opendata on
https://openapi.taifex.com.tw/v1/DailyForeignExchangeRates
When I browse it from chrome, I will get a file as follows.
enter image ...
0
votes
0
answers
30
views
Getting different response with Postman and Java rest client [closed]
I am trying to access a rest web service from Java client using HttpsURLConnection class.
Code Snippet:
URL url = new URL("<URL_HOST_NAME>/api/auth/login");
String ...
0
votes
1
answer
32
views
How to mock HttpUrlConnection in JAX-RS
I am trying to do a mock test for my class, but it does not work.
Original class:
public class Service {
.................
@POST
...
public Message Info(@NotNull @Valid final UUID Id) throws ...
0
votes
0
answers
35
views
How can I fire concurrent requests using java.net.HttpURLConnection? Can I do so? [closed]
I want to test my filter class against concurrent requests. Below is the code in which I am halting only the first request for some seconds and checking whether other requests execute or not. For this,...
0
votes
1
answer
32
views
How to save ZIP file from HttpURLConnection response
I am trying to save the zip file i am receiving from a service call . Below is the code i am trying to save it . Am not getting any error but not getting the extension .
ReadableByteChannel ...
1
vote
0
answers
26
views
Do I need close InputStream of HttpUrlConnection if I never call getInputStream?
The scenario is I only need to read some values from the HTTP response header. So I never called the httpUrlConnection.getInputStream() or httpUrlConnection.getContentLength().
Do I need add ...
0
votes
1
answer
24
views
Server returned HTTP response code: 400 for oauth token generation in java httpurlconnection
Tried to generate access token using oauth grantType password.But getting java.io.IOException: Server returned HTTP response code: 400 for URL: https://Host/nidp/oauth/nam/token. please find the below ...
-1
votes
0
answers
31
views
Exception in thread "Check Internet Thread" java.lang.NoClassDefFoundError: Could not initialize class okhttp3.OkHttpClient
Development Tool :
Eclipse DSL Tools (includes Incubating components)
Version: 2022-03 (4.23.0)
Build id: 20220310-1457
Project build on javafx.
Trying to run project getting error Could not ...
0
votes
0
answers
21
views
java HttpURLConnection.addRequestProperty "Authorization" doesn't work
I'm building a java 8 console program to get data from a remote web service.
That service needs an authorization token in the form:
"Authorization: Bearer <my token>".
My connection ...
0
votes
0
answers
16
views
Timeout occurred in java httpurlconnection only when user-agent request header is present
I need to read a website response and parse it, I am using java HttpsURLConnection class. Timeout error occurs when I add user-agent header . without this header I can read the response.
curl command ...
-1
votes
0
answers
28
views
HttpsURLConnection no header property
I have this code in Java 8
String u = "https://test.com/prova";
URL url = new URL(u);
System.out.println("Link: " + u);
HttpsURLConnection con = (HttpsURLConnection)url....
0
votes
0
answers
36
views
connection not closed after timeout exception
when retrieving a file I can't close the connection in case of timeout, when the timeout exception throws, i want to skip the file and pass to the next file.
.... java.net.sockettimeoutexception : ...
0
votes
0
answers
28
views
how to connect Restful API and socket server in java
I created restful API(with maven) which connect to MySQL. I want to connect with the Java socket server I created earlier. But I couldn't figure out how to do this. I tried to connect with ...
0
votes
1
answer
33
views
Getting connection timeout to URL, which I'm otherwise able to connect via browser in the same system
Due to company policies, I cannot share the complete code here, but here is where the code fails:
try(InputStream in = new URL("URL with image file").openStream()){
Files.copy(in,...
0
votes
0
answers
16
views
Java Rest : 400. The request is badly formed : URL contains -> api/Components(848569)/Properties('Stakeholder|Application Manager')
My URL is:
https://te.avolutionsoftware.com/api/Components(848569)/Properties('Stakeholder|Application Manager')
When i am using
allowMethods("PATCH");
HttpURLConnection conn = (...
0
votes
1
answer
23
views
React website showing "Not secured" hosted through GoDaddy
I have created a basic ReactJs website and hosted it using GoDaddy cPanel and secured domain through "Punchsalad" site using free SSL for 90 months. Website link is: http://www.paperware.co....
0
votes
0
answers
33
views
login via HttpURLConnection return status code 200 while it should redirect
I tries to login to the website using username and password. when I make a #HttpURLConnection and post it, the status code is 200 but it actually doesn't login. when I checked the login process with ...
0
votes
0
answers
23
views
How to check if Referer is empty or not before downloading
I have this two URL
From this website https://wvw1.123movies.net/ I got this URL
https://s02.eplayvid.net/vids/mars.attacks.1996.720p.brrip.x264.yify.mp4
and from https://oceanofapk.com/ I got this ...
0
votes
0
answers
14
views
Android HttpsURLConnection: getErrorStream works but not getInputStream
I want to get a json string from my remote server.
I have a very weird problem as I manage to get my json string only thanks to getErrorStream but not thanks to getInputStream.
Here is my code:
URL ...
0
votes
1
answer
36
views
How to solve KeyError: 400 Bad Request
I have a server to which I want to send post requests in the form of json in Java. But after sending, it gives the answer: "KeyError: 400 Bad Request: The browser (or proxy) send a request that ...
1
vote
0
answers
477
views
Java: After 5 minutes java.net.SocketException: Connection reset by peer | Even after SSLContextFactory
Server has limit of 10 Minutes or more.
It is working fine when I curl from server itself and access from my browser (chrome or opera)
when i try from Java code (1.8):
try {
URL url = new ...
0
votes
0
answers
91
views
Why doesn't Retrofit get a faster response after the first request?
I am doing some research on Retrofit and AsyncTask.
I write a simple code that use AsyncTask + HttpUrlConnection to send a GET reuest to jsonplaceholder to retrive some json sample. And the respond ...
0
votes
0
answers
28
views
Using a new connection vs. reusing connection in cURL
I'm doing cURL now and I found this tutorial -> https://www.phponweb.com/curl-get-post that uses CURLOPT_FRESH_CONNECT
After reading -> https://curl.se/libcurl/c/CURLOPT_FRESH_CONNECT.html it ...
0
votes
1
answer
30
views
Response Code 301 while sending request from Android
I need help, my app was working fine but after renew of Domain name, I started getting error 301. Is something to be fixed in my below code? Though if I use https://Google.com with same code, response ...
0
votes
0
answers
106
views
How to handle java.io.FileNotFoundException: in FileOutputStream?
I'm using Httpurlconnection and Fileoutstream to write/download file from Internet on android 12.
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/Download" + &...
0
votes
0
answers
30
views
Getting "No such property: getResponseCode for class: sun.net.www.protocol.http.HttpURLConnection" when the app is running
This is bit wired as "sun.net.www.protocol.http.HttpURLConnection" class is already extending java.net.HttpURLConnection abstract class which has the getResponseCode() public method. App is ...
0
votes
0
answers
21
views
How to make Multiple Post Request using Persistent Connections & Get the response for each request. I am using Java HttpURLConnection Class
I am new to Api.
Aim:- Is to perform Persistent Connections, as opposed to opening a new one for every single request/response pair. Currently I am only getting response for the first request. And for ...
0
votes
0
answers
21
views
ReactJs UI not able to call rest api service in some particular scenarios, loosing the connectivity between UI and rest api
We are using ReactJs(version "16.6.1") as frontend and .Net framework(version 4.7.2) as backend.
We are calling one Rest api service (developed in c#) from frontend reactJs (UI) and if the ...
0
votes
0
answers
10
views
URLConnection for Facebook works differently on Android Studio and Intellij
So what I am trying to do is to grab Facebook page's source code and work on it. However, I have found that when the same piece of code runs on Intellij IDEA, it works perfectly. All contents are ...
0
votes
0
answers
12
views
URLConnection on Android Studio returns less data compared to Intellij IDEA
recently I'm trying to grab a Facebook page's source code and work on it. However, I have discovered that the data returned from Intellij IDEA is different from Android Studio where those data is ...
0
votes
0
answers
16
views
How to extract the Cookie header from a GET request in java? [duplicate]
I tried searching all over the web but did not find anything useful. I built a java program that sends a post request with specific parameters to a website, and the user writes his/her personal_number ...
0
votes
0
answers
61
views
Properly close of URLConnection using openStream method
I'm getting a little bit confused about how properly close/manage an URLConnection/HttpURLConnection, the next code shows how I'm deal with it:
String someIP = "...";
URL url = new URL(...
0
votes
0
answers
193
views
Connection closed before full header was received pub finished with exit code 69
I can not add plugins into flutter, because I got this error message
"Connection closed before full header was received
pub finished with exit code 69
"
how cloud I fix this
I need fix this ...
0
votes
0
answers
18
views
HTTPUrlConnection and serverside abortion
If a server has limit on POST-submissions - and aborts the connection when limit is reached, giving a response-code and a response-text, it's impossible to get this from the java-class, because ...
0
votes
2
answers
42
views
How can I use a variable from the same class but different method in Android?
I've recently picked up Java and I'm trying to make a simple application in Android Studio that can access API. I'm trying to use HttpURLConnection but I'm having issues with classes, I get errors ...
0
votes
1
answer
50
views
HttpURLConnection ignores proxy
Android 6.0 - 11.0.
СompileSdkVersion 30
minSdkVersion 23
HttpURLConnection ignores proxy - when specifying a non-existent address, it does not swear.
I need that after compiling the application, the ...
0
votes
1
answer
48
views
Howto handle connection timeout errors for URLConnection (Java, Android)
I have the following code:
try {
url = new URL(sURL);
URLConnection connection = url.openConnection();
connection.setConnectTimeout(1000);
...
0
votes
0
answers
34
views
Java: Is there any way to get context of single sign on done on local system through code?
My company uses multiple applications and single sign on using Microsoft login.
In my browser, I already login to application but when run incognito mode, it again ask for login and MFA.
Now i want to ...
-2
votes
1
answer
57
views
How to get response from a http connection in android
I'm trying to handle this API http://worldtimeapi.org
Here is my code :
@Nullable
public String getResponseFromHttpUrl(@NonNull URL gotUrl) {
Log.v(LOG_TAG, "URI : " + gotUrl);
...
0
votes
1
answer
76
views
How to properly post url in android with java using HttpURLConnection
I try to use HttpURLConnection to send a post request to my local (xampp) server with an url like this http://xxx.xxx.0.3/Company/index.php/booking/c200/p-205/2025-02-09 8:2 , the server php file take ...
0
votes
0
answers
179
views
HttpURLConnection getResponseCode() API call gets stuck for ~30 mins on POST request and then returns IOException
I'm facing issue of my client app getting hanged for long duration while trying to send a POST request. My connection timeout is 5sec and read timeout is 240 sec. But, the request gets stuck in wait ...
2
votes
1
answer
85
views
HttpURLConnection connecting to a localhost works on Android 7 but not on Android 10
This is a simple code sample that I use to write/read a message to/from a localhost. I tested on an Android emulator. It works on Android 7 but not on Android 10. On Android 10, I found the program ...
1
vote
0
answers
93
views
Invalid Token Java Post Get/Post Request
I am new to Rest API based on Java. The purpose is to obtain an access token from a particular API Token URL by sending a POST request. However, upon running the following program, the access token ...
0
votes
1
answer
55
views
Issue creating URL Connection with the url having "%E2%80%93"
I'm trying to download file from the following URL
File URL. The problem is when I try to read anything from open connection like header or stream, the Unescape(%e2%80%93) character in URL get replace ...
1
vote
1
answer
446
views
Exception : java.lang.IllegalStateException: Already connected
Hi I'm trying to use HttpURLConnection to send some POST data to a server using the HttpURLConnection class as shown below but it is throwing "java.lang.IllegalStateException: Already connected.&...
0
votes
1
answer
15
views
android - unable to post large data via Uri.Builder
I post my data via Uri.Builder to the server . I've a very large data in my variable , this is the data :
630#738#6589#7772#7771#7769#7768#7767#7766#7765#7764#7763#7762#7761#7760#7759#7758#7757#7756#...
0
votes
2
answers
143
views
UrlConnection API Call takes much more time the first time, then onwards it is comparable to curl.exe or postman
I have observed that one of my api is taking much more time if called through Java (URLConnection or Apache Http Client or OKHttp) for the first time. For the subsequent calls, the time is much lesser....
0
votes
0
answers
467
views
How to send binary file using HttpClient approach
I am trying to send a two binary file to one of the REST API. But I get 400 bad request response from the end point.
Need to send below key and values to endpoint.
userForm - user.xml
structureForm - ...