3

New to pyral, trying to add a task to a user story. Copy pasted already available, "seems working" code from net.

code:

target_story   = rally.get('UserStory', query='FormattedID = %s' % storyID, instance=True)

    info = {
             "Project"     : project,
             "WorkProduct" : target_story.ref,
             "Name"        : "USER of of ",
             "State"       : "Defined",
             "TaskIndex"   : 1,
             "Description" : "FXYZ.",
             "Estimate"    : 2.0,
             "Actuals"     :  1.0,
             "ToDo"        : 1.0,
             "Notes"       : "XYZ"
           }

    task = rally.put('Task', info)

Error I am getting:

Traceback (most recent call last):
  File "...projects/Timer/task.py", line 113, in <module>
    main()
  File "...projects/Timer/task.py", line 70, in main
    task = rally.put('Task', info)
  File "...Python27\lib\site-packages\pyral\restapi.py", line 947, in put
    response = RallyRESTResponse(self.session, context, resource, response, "shell", 0)
  File "...\Python27\lib\site-packages\pyral\rallyresp.py", line 117, in __init__
    self.content     = json.loads(response.content)
  File "...\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "...\Python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "...\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Thanks in advance. Note: already checked: https://github.com/RallyTools/RallyRestToolkitForPython/issues/21 pyral ver: 1.1.1

vinay
  • 31
  • 2

1 Answers1

0

I've updated code given above and now it works:

target_story_req = rally.get('UserStory', query='FormattedID = %s' % storyID)
target_story = target_story_req.next()

project_req = rally.get('Project', fetch=True, query='Name = "%s"' % (projectID))
project = project_req.next()

info = {
         "Project"     : project.ref,
         "WorkProduct" : target_story.ref,
         "State"       : "Defined",
         "TaskIndex"   : 1,
         "Description" : "FXYZ.",
         "Estimate"    : 2,
         "Actuals"     : 1,
         "ToDo"        : 1,
         "Notes"       : "XYZ"
       }

task = rally.create('Task', info)
user2738882
  • 1,161
  • 1
  • 20
  • 38