Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

POST request to import workflow XML

Hi,

I'm a Jira admin and I'm trying to develop a python script to import XML workflows through the workflow XML definition option from:

<Base URL>secure/admin/workflows/ImportWorkflowFromXml!default.jspa

I'm using the "request" module to do a POST call and send the data to the form in above URL but, the only thing that the POST call it's doing it's to fill the form without  submitting it.

I have checked the chrome dev tools to monitor the POST call from the browser to mimic and send the same payload, headers, URL, etc. But without success.

I'm using PyCharm and Postman to test the POST requests and in both tools I'm getting 200 response code while in the browser I get a 302 response code, which is normal because it redirects the request to "/secure/admin/workflows/ListWorkflows.jspa" once the form is submitted, but I can't get the same behavior from PyCharm or Postman.


Python Script


import requests
import json

url = 'https://<Base URL>/secure/admin/workflows/ImportWorkflowFromXml!default.jspa'
headers = {
"Authorization": "<Personal Access Token>"
}
form_data = {
"name": "testing",
"description": "",
"definition": "inline",
"filePath": "",
"workflowXML": '<XML Workflow Definition>',
"Import": "Import"
}

with requests.session() as s:

s.get(url, headers=headers) #//Getting the cookies and Session ID

headers['Cookie'] = '; '.join([x.name + '=' + x.value for x in s.cookies])
headers['Content-Type'] = 'application/x-www-form-urlencoded'
headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
headers['Accept-Encoding'] = 'gzip, deflate, br'
s.headers.update(headers)

post_response = s.post(
url,
form_data,
cookies=s.cookies
)

print
(post_response.text)
print(post_response.status_code)

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events