First, I would switch to using system.net.httpClient()
. It’s better in a myriad of ways.
For a concrete example, you can directly post your JSON content as a Python dictionary:
accessToken = '<myUsername>:<JIRA_API_Token>'
uri = "http://<My Company's JIRA Project page>"
headers = {"Authorization":"Basic " + accessToken}
issueData = {
"fields": {
"project":
{
"key": "VPI"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Bug"
}
}
}
response = system.net.httpClient().post(url = uri, data = issueData, headers = headers)
print response
For your specific question, you can use various Python builtin modules to encode to base64, or an Ignition builtin, or one from the Java standard library. There’s not really a lot of difference. For instance:
toEncode = "<myUsername>:<JIRA_API_Token>"
from base64 import b64encode
print b64encode(toEncode)
from java.util import Base64
print Base64.getEncoder().encodeToString(toEncode)
Both print the same output, but the ‘Java way’ is a whole lot more verbose