Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3907 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hi,

 

I have scriptmaster running with Post Data to URL.

But there is problems with authentication.

 

My parameters is:

URL: https://api.operatorspage.com/2/sms/

VALUE: "batch_label": "Test", "message": "Hello world!"

KEY: Authorization Token zxczxczxczxc

 

How can I POST data to URL without get back this error?

java.io.IOExeption: Server returned HTTP response code: 401 for URL: https://api.operatorspage.com/2/sms/

 

My code:

 

// Construct data

String data = URLEncoder.encode(key, "UTF-8") + "=" + URLEncoder.encode(value, "UTF-8");

// use something like the following to send multiple key/value pairs

// data += "&" + URLEncoder.encode(key2, "UTF-8") + "=" + URLEncoder.encode(value2, "UTF-8");

 

// Send data

URL url = new URL(url);

URLConnection conn = url.openConnection();

conn.setDoOutput(true);

OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());

wr.write(data);

wr.flush();

 

// Get the response

String response = conn.getInputStream().getText("utf-8");

wr.close();

return response;

 

Thanks!

/Stefan

This topic is 3907 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.