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