Jira APIs inconsistent responses in Python and React

Hi all,

I encountered some issues with JIRA API request in my current project. Mainly api.atlassian.com/ex/jira doesn’t have a consistent response.

These are the testing tools that I used.

  • OS: ubuntu 22.04
  • Python (3.10) requests lib
  • React (18+) with Axios
  • Curl 7.81.0

Issue

I’m encountering a perplexing issue with OAuth 2.0 integration apps that I’ve created in the Atlassian Developer Console (Developer console ). The responses between apps are quite baffling even thought they are identical for all apps.

My steps are:

  • I created multiple OAuth 2.0 integration apps (for different redirect URLs purpose in the future) with exactly the same settings.
  • The first app works perfectly for both Confluence and Jira OAuth.
  • However, the second app doesn’t work with Jira. It shows the error message: “Something went wrong. Close this page and try again, or raise a support request.”
  • The third app doesn’t work for both Confluence and Jira, displaying the same error message.

API responses are also inconsistency. According to JIRA document, when I sent curl request to JIRA API, I always get 200 from request. The API also works with Elixir Tesla. Example:

curl --request GET \
  --url '<https://api.atlassian.com/ex/jira/<CLOUD_ID>>/rest/agile/1.0/board' \
  --header 'Authorization: Bearer <TOKEN>' --header 'Accept: application/json'

The issue arises in using the same API with React 18 and Python.
I get inconsistent returns 400 - Bad request or unauthenticated without any indicators.

let accessToken = "example access token"
let cloudID = "example cloud id"

const requestOptions = {
  headers: { Authorization: `Bearer ${accessToken}`, Accept: ' application/json' },
};

axios.get(`https://api.atlassian.com/ex/jira/${cloudID}/rest/agile/1.0/board`, requestOptions)
          .then((response) => {
            console.log(response)
          })
          .catch((error) => {
            console.log(error)
          })

With Python, once add request params (such as request_params = {“maxResults”: 1000} ), it gives 400 - Bad.

import requests
import logging

def jira_request() -> None:
    HTTPConnection.debuglevel = 1
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True
    
    url = "<https://api.atlassian.com/ex/jira/<CLOUD_ID>/rest/agile/1.0/board/1/issues"
    url = "<https://api.atlassian.com/ex/jira/<CLOUD_ID>/rest/agile/1.0/board/1/issues?maxResults=10" # FAIL

    request_params = {"maxResults": 1000}

    headers = {
        "User-Agent": "curl/7.81.0",
        "Accept": "application/json",
        "Accept-Encoding": "identity",
        "Authorization": "Bearer <TOKEN>",
    }

    response = requests.get(url, headers=headers, params=None) # SUCCESS
    response = requests.get(url, headers=headers, params=request_params) # FAIL


if __name__ == "__main__":
    jira_request()


################## Results ###############################

reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Thu, 13 Jun 2024 04:26:25 GMT
header: Content-Type: text/html;charset=utf-8
header: Content-Length: 435
header: Server: AtlassianEdge
header: Content-Language: en
header: X-Trace-Id: 68cf738f45304ecb933b276e383ce792
header: X-Frame-Options: SameOrigin
header: X-Content-Type-Options: nosniff
header: X-Xss-Protection: 1; mode=block
header: Atl-Traceid: 68cf738f45304ecb933b276e383ce792
header: Strict-Transport-Security: max-age=63072000; preload
header: Report-To: {"endpoints": [{"url": "<https://dz8aopenkvv6s.cloudfront.net>"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}
header: Nel: {"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}
DEBUG:urllib3.connectionpool:<https://api.atlassian.com:443> "GET /ex/jira/<CLOUD_ID>/rest/agile/1.0/board/1/issue?maxResults=10 HTTP/1.1" 400 435

I have tried various libraries in Python such as HTTPX and aiohttp, but none of these worked.
Also, to point out that I have not faced any issue while working with Confluence APIs.
The above issue is with Jira APIs.

I would appreciate guidance to resolve this issue.