Skip to Content
avatar image
Former Member

starting channel through

Hi All

I tried starting channel through UDF i had all the authorizations .but getting 401 response code

URL server = new URL("http://host:port/AdapterFramework/ChannelAdminServlet?party=&service=""&channel=""r&action=start");

//Hard code User Name & Password

String userPassword = "username" + ":" + "password";

URLConnection uc=server.openConnection();

uc.setRequestProperty ("Authorization", userPassword);

uc.connect();

BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream()));

String inputLine = "";

String output = "";

while (( inputLine = br.readLine()) != null)

output+=inputLine;

System.out.print(output);

br.close();

please let me know if this is wrong..please help me to achieve it

Regards

Sandeep

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 08, 2011 at 10:56 AM

    Hi

    Try with this URL

    http(s)://host:port/AdapterFramework/ChannelAdminServlet?party=party&service=service&channel=channel&action=start

    URL server = new URL("http://host:port/AdapterFramework/ChannelAdminServlet?
    party=&service=""&channel=""*r*&action=start");

    is it required here or is it a typo error?

    regards

    Ramesh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi ramesh

      The url works fine when i run url in browser. it starts and stops channel accordingly.

      I need help on UDF

      Regards

      Sandeep

  • avatar image
    Former Member
    Dec 08, 2011 at 11:34 AM

    Hi Sandeep,

    I am not sure about the code, but can you try?

    Since it is URL you need to POST it right?

    Add these lines instead of

    HttpURLConnection uc =(HttpURLConnection) new
                                    URL(server).openConnection();
    uc.setDoOutput(true);
    uc.setRequestMethod("POST");
    
    
    
    URLConnection uc=server.openConnection();
    uc.setRequestProperty ("Authorization", userPassword);
    uc.connect();

    Regards

    Ramesh

    Add comment
    10|10000 characters needed characters exceeded