I am successfully using Postman to send a GET Request to a corp. Jira server*, which is a Windows server hosting a local instance of Jira within our corp. network. The response.text contains the expected data. For example at the beginning of the response, I see:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="application-name" content="JIRA" data-name="jira" data-version="9.4.7">
...
- I edited the actual url to a simplified, anonymous string, and removed all auth/cookie info.
However (and this seems to be a common issue according to google), when I use the generated code snippet for python, instead of getting the expected response, I get something from Microsoft:
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html dir="ltr" class="" lang="en">
<head>
<title>Sign in to your account</title>
...
</head>
<body data-bind="some stuff">
<script type="text/javascript">some more stuff</script>
</body>
</html>
Here is the generated code snippet:
import requests
url = "https://jira_server.com/issues/?jql=xxx"
payload = {}
files={}
headers = {
'Authorization': 'Basic string',
'Cookie': 'string'
}
response = requests.request("GET", url, headers=headers, data=payload, files=files)
print(response.text)
Note: I am sending the same authorization credentials via the script as is being sent by Postman - this is not a user-agent issue; I have tried it with user-agent set and the result is the same, which is that the response I am getting, appears to be from the server hosting Jira (or a dns server that redirects to the host?)
I have also tried adding all the headers that are present in Postman (including the user-agent), but no change.
Finally, I tried the following:
Python - http.client:
import http.client
import mimetypes
from codecs import encode
conn = http.client.HTTPSConnection("jira_server.com")
boundary = ''
payload = ''
headers = {
'Authorization': 'Basic string',
'Cookie': 'string',
'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("GET", "/issues/?jql=xxx", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response:
<!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title>...</head></html>
Any assistance will be greatly appreciated, thx!