pythonpython-2.7jython-2.7

how to compare variables from api call, and the condition is met but it still not giving any output or error, program completes


I want to reference two variables in if condition

def remedialIssue(self, branch, issue_id, new_status):
    AppBranch = request.get("/rest/api/latest/issue/" + str(issue_id), params=querystring, contentType='application/json')
    appbranch = json.loads(AppBranch.response)
    appbranch = u" {0}".format(appbranch['fields']['customfield_1000'])
    appbranch = str(appbranch)
    branch = str(branch)
    print(appbranch)
    print(branch)
    if appbranch == branch:
        print "error"

branch is passed from external app GUI which calls this function but even if the condition is met, it is not giving any output or error, just completes program.


Solution

  • Your condition tests that appbranch and branch are equal. Since you are placing a space in front of appbranch, this seems unlikely:

    u" {0}".format(...)
    

    Unless branch also starts with a space?