Problem when trying to use (getResponseCode())

29 views Asked by At

I have a problem in my code, I'm programming for a platform called FLUIG, in this context I need to make a call to an endpoint, but when I try to use the getResponseCode() method my code dies.

var apiC = new java.net.URL(strUrl); 
    var consumo = apiC.openConnection(); 
    responseGET = strUrl;
    
    
    //consumo.setDoOutput(!0); 
    consumo.setConnectTimeout(18e4); 
    consumo.setReadTimeout(18e4); 
    consumo.setRequestMethod("GET"); 
    consumo.setRequestProperty("Authorization", "Bearer " + Token); 
    consumo.setRequestProperty("Accept", "application/json"); 
    consumo.setRequestProperty("Content-Type", "application/json"); 
    consumo.setRequestProperty("tenant", l); 
    var intResponseCodeGET = consumo.getResponseCode();
    consumo.setDoOutput(true);
    
    
    
    //new  
    var intResponseCodeGET = ""
        intResponseCodeGET = (consumo.getResponseCode()).toString();
    
    responseGET = intResponseCodeGET;
    if( intResponseCodeGET == "200" || intResponseCodeGET == "201" )
    {   
        responseGET = "ok";
    }

I would like to know why and how to fix this problem

0

There are 0 answers