Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String username = "i4niac"
- String password = "mypassword"
- // Create authorization header using Base64 encoding
- String userpass = username + ":" + password;
- String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
- // Create URL
- URL url = branchesUrl.toURL()
- // Open connection
- URLConnection connection = url.openConnection()
- // Set authorization header
- connection.setRequestProperty ("Authorization", basicAuth)
- // Open input stream
- InputStream inputStream = connection.getInputStream()
- // Get JSON output
- def branchesJson = new groovy.json.JsonSlurper().parseText(inputStream.text)
- // Close the stream
- inputStream.close()
Add Comment
Please, Sign In to add comment