lbRequest added
This commit is contained in:
parent
484fa2004f
commit
f38bbb445c
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env groovy
|
||||
|
||||
def call(String apiUrl, String user, String pass, String url) {
|
||||
def response = httpRequest(
|
||||
url: "${apiUrl}/accounts/login",
|
||||
httpMode: 'POST',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
requestBody: writeJSON(json: [
|
||||
'user': user,
|
||||
'password': pass
|
||||
], returnText: true)
|
||||
)
|
||||
def login = readJSON text: response.content
|
||||
|
||||
httpRequest(
|
||||
url: "${apiUrl}/${url}",
|
||||
customHeaders: [[name: 'Authorization', value: login.token]]
|
||||
)
|
||||
httpRequest(
|
||||
url: "${apiUrl}/accounts/logout",
|
||||
httpMode: 'POST',
|
||||
customHeaders: [[name: 'Authorization', value: login.token]]
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue