Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create filters from C# program through the REST API's

Johan Hallin
Contributor
October 25, 2021

So, 2 years ago I wrote a program in C# (command based) which created filters through the Jira API's using a POST-call to the API. I got everything working and created around 200 filters using this method. 

Now to my problem, I manage to loose the code and program when my laptop crashed and unfortunately I did not have a backup of the code. (stupid, I know). 

Now when I try to do the same thing again (using a more fancy WinForm application in visual studio with C#) I can't remember how I did it. I'm pretty sure I worked with a string containing the JQL, something like <jira url>/rest/api/2/filter/?jql=project%20%3D%20SWE" (or something similar. (SWE is the project key in Jira).

Does anyone have a good example of C# and creating filter? Any ideas which way to go, using a HttpClient or HttpWebRequest or something?  

I have tried those and get a lot of 400 or 415 issues as a response. 

Kind regards, J

1 answer

0 votes
Thomas Deiler
Community Champion
October 27, 2021

Dear @Johan Hallin 

<jira url>/rest/api/2/filter/?jql=project%20%3D%20SWE"

This looks more like a GET filter then a POST for creating one.

It just simple. You need to perform a POST to

<jira url>/rest/api/2/filter

with following JSON payload:

{
  "name": "My API created filter",
"description": "some more details",
"jql": "project = SWE",
"favourite": false,
"editable": true
}

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, aafp, jira migration, marketing collaboration, end siloed work, streamline workflows, kerrie gottschalk, jira cloud admins, unified marketing, process visibility, team efficiency, cross-team collaboration

How Kerrie Gottschalk unified AAFP’s marketing team with Jira

At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.

Read the story
AUG Leaders

Atlassian Community Events