I am actually trying to call some Azure devops API using Basic Authentication and Personal Token. This inside groovy script in Jira script runner
based on official documentation is is mentionned that the token need to be converted to Base64 as explain in the following link : Pwrsonal Token
Then in my groovy script I encode my token as below :
String _AuthToken ="itecor:[my personnal token]".bytes.encodeBase64().toString()
Then in my API call I pass the Token to the header as below :
def http = new HTTPBuilder(graph_base_Url)
http.request(POST) {
requestContentType = ContentType.JSON
body=[
definitionId: _definitionId,
variables: [ InstanceNum: _instanceNb,
Version: _version
]
]
headers.'Authorization' = "Basic ${_AuthToken}"
response.success = { resp, json ->
_jobInfo=json.toString()
}
Then when executing my code, I get the error : "status code: 401, reason phrase: Unauthorized"
Any idea what I am doing wrong ?
Regards
Issue has been solved. Error was coming from a corrupted token