lbRequest added

This commit is contained in:
Juan Ferrer 2022-06-21 01:01:08 +02:00
parent 484fa2004f
commit f38bbb445c
1 changed files with 24 additions and 0 deletions

24
vars/lbRequest.groovy Normal file
View File

@ -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]]
)
}