# Can't connect to Channels/Users API (java)

**URL:** <https://discuss.dev.twitch.com/t/cant-connect-to-channels-users-api-java/4817>\
**Category:** API\
**Created:** [February 17, 2016, 1:10pm UTC](https://discuss.dev.twitch.com/t/cant-connect-to-channels-users-api-java/4817 "2016-02-17T13:10:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![welldooder64](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@welldooder64](https://discuss.dev.twitch.com/u/welldooder64)\
**Post date:** [February 17, 2016, 1:10pm UTC](https://discuss.dev.twitch.com/t/cant-connect-to-channels-users-api-java/4817/1 "2016-02-17T13:10:48Z")

</div>

I’m trying to get the channels and users API for my channel but every time I try to retrieve it, It returns a FileNotFoundException / 404 error.  
[https://api.twitch.tv/kraken/streams/[user]](https://api.twitch.tv/kraken/streams/%5Buser%5D) is the only API that does work.

This is the function I use to do the request:

```
public static String getJson(String URL){
	StringBuilder result = new StringBuilder();
	HttpsURLConnection con;
	
	try {
		con = (HttpsURLConnection) new URL(URL).openConnection();
		con.setRequestMethod("GET");
		con.setDoOutput(true);
		con.setRequestProperty("Accept", "application/vnd.twitchtv.v3+json");
		con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
	        OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
	        out.flush();
	    
	        InputStream in = new BufferedInputStream(con.getInputStream());
                BufferedReader reader = new BufferedReader(new InputStreamReader(in));
                String line;
                while ((line = reader.readLine()) != null) {
                    result.append(line);
                }    
	} 
        catch (Exception e) {
		e.printStackTrace();
	} 
	return result.toString();
}

```

Does anyone know how to fix this?

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [March 18, 2016, 1:10pm UTC](https://discuss.dev.twitch.com/t/cant-connect-to-channels-users-api-java/4817/2 "2016-03-18T13:10:48Z")

</div>

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