Help: HTTP Request with VP

Hey guys,
I am currently struggling with an HTTP Request.
We’ve got a platform with all Objects either classes/tables etc. and I’m trying to receive those informations (which class/stereotype) so i can simply model them with my plugin instead of doing those manually.

However I’ve written an http request which does work in eclipse, but if i put it into my plugin it does not work.

to simplify i just tried to send a request to a website, than put the info into an array an print out just a single String but VP stops the moment the http request starts.

Any ideas what’s wrong?

I’m working with VP 10.2
my code

public class ClassGeneratorActionController implements VPActionController{
public void performAction(VPAction action) {

	ViewManager viewManager = ApplicationManager.instance().getViewManager();
	HTTP_Request almost = new HTTP_Request();
	String[][] table = almost.sendRequest();

//HTTP_Request Class

import org.json.JSONArray;
import org.json.JSONObject;

public class HTTP_Request {

public String[][] content;

public String[][] sendRequest(){
try {
String url = ""; //TABLE

  URL obj = new URL(url);
  HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  BufferedReader in = new BufferedReader(
  		new InputStreamReader(con.getInputStream()));
  String inputLine;
  StringBuffer response = new StringBuffer();
  while ((inputLine = in.readLine()) != null) {
 JSONObject myresponse = new JSONObject(response.toString());
 JSONObject d_object = new JSONObject(myresponse.getJSONObject("d").toString());
 JSONArray results = new JSONArray(d_object.getJSONArray("results").toString());
 content = new String[results.length()][2];
 for(int i = 0; i<results.length();i++) {
	JSONObject stereo = results.getJSONObject(i);
		 content[i][0] = stereo.getString("RET_VALUE");
		 content[i][1] = stereo.getString("RET_NAME");

  } catch (Exception e) {

return content;	

I’ve used the java-json.jar
Thank you

just forgot to add the jar library…

If VP stopped then it sounds like your HTTP request isn’t responding as it should. Do you get any error logs within the console?

You might need to specify some additional request properties such as a request method which is mentioned in this link :

We use the following libraries and we have no problems making requests and iterating over its response:

  • org.json.simple