Rally Software

 View Only
Expand all | Collapse all

json error with pyral trying to update collections ( addCollectionItems )

  • 1.  json error with pyral trying to update collections ( addCollectionItems )

    Posted Nov 18, 2020 07:05 PM
    I'm getting a json error when trying to add a tag in a PortfolioItem with the addCollectionItems. Code below.

    USAGE = """\
    Usage: python addtags.py <Feature_id> <tag_name> <tag_name> <tag_name>...
    """

    Feature_id = args.pop(0)
    tag_names = args[:]
    tags = []
    response = rally.get('Tag', fetch=True, order="Name", server_ping=False, isolated_workspace=True)
    for tag in response:
    if tag.Name in tag_names:
    tags.append(tag)

    Feature = rally.get("Feature", fetch="FormattedID,Name,Description,Tags,_type",
    query="FormattedID = %s" % Feature_id, server_ping=False, isolated_workspace=True, instance=True)
    Feature_tags = [str(tag.Name) for tag in Feature.Tags]
    print("Preexsisting tags : ",Feature_tags)

    adds = rally.addCollectionItems(Feature, tags)


    I get this error :

    Traceback (most recent call last):
    File "/ws/eduran-ott/vpython/lib/python3.5/site-packages/pyral/rallyresp.py", line 124, in __init__
    self.content = response.json()
    File "/ws/eduran-ott/vpython/lib/python3.5/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
    File "/sw/packages/python3/3.5.0/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
    File "/sw/packages/python3/3.5.0/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "/sw/packages/python3/3.5.0/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "./add.tag.py", line 102, in <module>
    main(sys.argv[1:])
    File "./add.tag.py", line 69, in main
    adds = rally.addCollectionItems(Feature, tags)
    File "/ws/eduran-ott/vpython/lib/python3.5/site-packages/pyral/restapi.py", line 1219, in addCollectionItems
    response = RallyRESTResponse(self.session, context, resource, response, "shell", 0)
    File "/ws/eduran-ott/vpython/lib/python3.5/site-packages/pyral/rallyresp.py", line 127, in __init__
    raise RallyResponseError(problem)
    pyral.rallyresp.RallyResponseError: Response for request: PortfolioItem/388668889576/Tags/add either was not JSON content or was an invalidly formed/incomplete JSON structure

    Any help is really appreciated.


  • 2.  RE: json error with pyral trying to update collections ( addCollectionItems )

    Posted Nov 18, 2020 11:55 PM
    Edited by Eduardo Duran Nov 18, 2020 11:55 PM
    (update) I was able to update the Tags of the portfolioItem using rally.update

    seems my mistake was to confuse Tags as collection items (so the use of addCollectionItems is not appropriate)

    this does work

    updateDict = {
    'FormattedID': Feature_id,
    'Tags': tags,
    }
    rally.update('Feature', updateDict)