Remote API (SOAP) Examples

All Versions

JIRA 4.0 Beta Documentation
More code examples can be found in the SVN repository. You may also try looking for them in the jira-user and jira-developer mailing list (or forum).

Perl

Logging In

#!/usr/bin/perl

use SOAP::Lite;
use Data::Dumper;

my $soap = SOAP::Lite->proxy("http://localhost:8090/rpc/soap/jirasoapservice-v2?wsdl");
my $auth = $soap->login("admin", "admin");

Creating Issue

$issueMap = {"project" => SOAP::Data->type(string => "YQ"),
            "components" => [{"id" => SOAP::Data->type(string => "10010")}],
            # this is definitely not working as "10010" will be 'autotyped' to int:
            # "components" => [{"id" => "10010"}],
            "type" => SOAP::Data->type(string => "1"),
            "summary" => SOAP::Data->type(string => "Issue created via Perl/SOAP")
           };

my $issue = $soap->createIssue($auth->result(), $issueMap);

Python

Logging In

#!/usr/bin/python

import SOAPpy, getpass, datetime, array, base64, random
from SOAPpy import Types
soap = SOAPpy.WSDL.Proxy('http://localhost:8090/rpc/soap/jirasoapservice-v2?wsdl')
jirauser='admin'
passwd='admin'

auth = soap.login(jirauser, passwd)

Adding User to Group

group = soap.getGroup(auth, 'foo')
user = soap.getUser(auth, 'admin')
user = {'name': user['name']} # without this line, you might be facing some funny problems. see JRA-7920.
soap.addUserToGroup(auth, group, user)

Listing Workflow Actions and associated Fields and Progressing

# List
actions = soap.getAvailableActions(auth, 'MYC-28')
print "actions:"
for action in actions:
  print action
  fields = soap.getFieldsForAction(auth, 'MYC-28', action['id'])
  for field in fields:
    print field;
  print "-----"

# Progress
issue = soap.progressWorkflowAction(auth, 'MYC-28', '5', [{'id': 'resolution', 'values': ['2']}, {'id': 'assignee', 'values': ['admin']}, {'id': 'comment', 'values': ['testo!']}])

Labels

soap soap Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Dec 04, 2008

    Tom Wilberding says:

    Here is a C# example: Stub code, or skeleton code, is a method of generating se...

    Here is a C# example:

    Stub code, or skeleton code, is a method of generating server class files based off a web service defintion file (WSDL). Most programming languages have SOAP tools designed to generate stub code from a WSDL file.

    Visual Studio .NET installs with an application called wsdl.exe which can be used to generate server stub code as well as client code to interact with that service. This file is usually located under the .NET SDK bin directory for example:

    C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\wsdl.exe
    

    The wsdl file supports converting a WSDL file into a .NET language stub/client code. There is a /language argument that can be used to specify the .NET language to generate the stub code file in. The default language is C#. Here are some examples commands using the WSDL file from our local JIRA installation.

    wsdl /language:CS http://jira/jira//rpc/soap/jirasoapservice-v2?wsdl
    

    This will generate a class called JiraSoapServiceService.cs that can be used to remotely access JIRA via C#.

    This class has quite a few methods (see class diagram below or javadocs above). Most can be called synchronously or asynchronously with an event handler.

    Here is a simple example program that uses the stub/client code to create a new issue in our JIRA server

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace JiraSoapClient
    {
        class JiraSoapClient
        {
            public static void createTestMessage()
            {
                System.Diagnostics.Debug.WriteLine("Creating a test issue on http://jira/jira ...");
    
                JiraSoapServiceService jiraSoapService = new JiraSoapServiceService();
    
                string token = jiraSoapService.login("jiraadmin", "*****");
                string projectStr = "DEV";
    
                RemoteProject project = jiraSoapService.getProjectByKey(token, projectStr);
    
                // Create the issue
                RemoteIssue issue = new RemoteIssue();
                issue.project = project.key;
    
                List issueTypes = new List(jiraSoapService.getIssueTypesForProject(token, project.id));
                foreach (RemoteIssueType issueType in issueTypes)
                {
                    if (issueType.name.Equals("Bug"))
                    {
                        issue.type = issueType.id;
                    }
                }
    
                List components = new List(jiraSoapService.getComponents(token, project.key));
                foreach (RemoteComponent component in components)
                {
                    if (component.name.Equals("MM - Strategies"))
                    {
                        issue.components = new RemoteComponent[] { component };
                    }
                }
    
                RemoteUser user = jiraSoapService.getUser(token, "tomw");
    
                issue.reporter = user.name;
    
                issue.summary = "This is a new SOAP issue " + DateTime.Now;
    
                RemoteIssue returnedIssue = jiraSoapService.createIssue(token, issue);
                System.Diagnostics.Debug.WriteLine("Successfully created issue http://jira/jira/browse/"+returnedIssue.key);
            }
    
        }
    }
    
    1. May 04

      Anonymous says:

      hi Tom Wilberding Your Example is very help full for beginaers...with the help ...

      hi Tom Wilberding

      Your Example is very help full for beginaers...with the help of this i get start working with JIRA API'S..but i m trying to do some more thing in C# like i want to show the list of all assignees in Dropdown list and want ot get the values of Custom field in Dropdown list attaching a single/multiple file into the issue.....

      any help will be appreciable pls help ...

      Thanks & Regards

      Rupesh Prasad

      1. May 07

        Rosie Jameson [Atlassian Technical Writer] says:

        Hi Rupesh, Could I suggest that you please try posting your question in the Dev...

        Hi Rupesh,

        Could I suggest that you please try posting your question in the Developers Forum? http://forums.atlassian.com/forum.jspa?forumID=100

        Many thanks,
        Rosie

  2. Jun 08

    Anonymous says:

    Hi Tom, Thanks for the creation example. Can you please give an example of upd...

    Hi Tom,

    Thanks for the creation example.

    Can you please give an example of updating an issue? I'm facing problems setting the value of RemoteFieldValue with C#.

    Thanks in advance,
    Jaspreet

  3. Jun 08

    Bob Swift says:

    You can look at the source for JIRA Command Line Interface.

    You can look at the source for JIRA Command Line Interface.

  4. Jun 16

    Anonymous says:

    How do I have an operation to add a value for a customfield?  I have s...

    How do I have an operation to add a value for a customfield?  I have searched through the WSDL API's but have not found any which does that.

    -Mahesh

    1. Jun 16

      Bob Swift says:

      See my comment above.

      See my comment above.

    2. Jun 16

      Timothy Chin says:

      You can check out the parent page: http://confluence.atlassian.com/display/JIRA...

      You can check out the parent page:

      http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client

      It has an example which you can use.

Add Comment


Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 2.5 Australia License.