Advertisement
Guest User

teste2

a guest
Feb 7th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. def username = "ekoppta"
  2. def password = "Rothivi@06"
  3.  
  4. def getBuilder = {
  5. String url = "https://mhweb.ericsson.se/rest/ping"
  6.  
  7. def http = new HTTPBuilder(url)
  8. http.client.addRequestInterceptor(new HttpRequestInterceptor() {
  9. void process(HttpRequest httpRequest, HttpContext httpContext) {
  10. httpRequest.addHeader("Authorization", "Basic " + "$username:$password".bytes.encodeBase64().toString())
  11. httpRequest.addHeader("Content-Type", "application/json")
  12. httpRequest.addHeader("externalSystemID", "MHWEB_EXCEL")
  13. }
  14. })
  15.  
  16. return http
  17. }
  18.  
  19. def http = getBuilder()
  20.  
  21. def result = http.request(GET, JSON) { req ->
  22. headers.Accept = 'application/json'
  23. body = """
  24. {
  25. "transition": {
  26. "id": "$transitionId"
  27. }
  28. }
  29. """
  30.  
  31. response.success = { resp, json ->
  32. return json
  33. }
  34. response.failure = { resp ->
  35. return resp.statusLine
  36. }
  37. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement