JQL API alternatives to x-www-form-urlencoded

  • New Participant
  • 2 replies

I’m writing a few custom JQL queries that I would like to run from a python script, and I find that the `application/x-www-form-urlencoded` content type requires a lot of formatting and escaping and (duh) encoding to get right. This is especially true for going from a parameters dict to the urlencoded version of it. Is there an alternative way to pass the payload, perhaps as a json?

2 replies

Badge +1

Hi @vlsd  -- 

Looks like the python code in our reference docs isn’t great. Here is a better example of the request could look like:

import requests
import json
import os
API_SECRET = os.getenv("API_SECRET").strip()
with open("script.js") as s:
script =
response = requests.request(
auth=(API_SECRET, ''),
"script": script,
"params": json.dumps({"from_date": "2017-01-01", "to_date": "2021-01-01"}),

query.js (in the same directory)

function main() {
return Events({
from_date: params.from_date,
to_date: params.to_date,

Does this help at all?

Oh yes, this is way more readable and easy to code. I will give it a try, thanks!