Using pyral to create a new feature associated with a SolutionCapability

342 Views Asked by At

I am trying to access the rest api's of Rally using PyRal library of python to try and create new features , I am able to create a feature but not able to associate to a SolutionCapability.

I have tried passing the SolutionCapability as Json in the Post request which creates the feature but the in the it give a parsing error, I have have also tried passing the ref to SolutionCapability Object,but that also does not work .

@app.route("/createFeature", methods=['POST'])        
def createFeature():
      parent = rally.get('PortfolioItem/SolutionCapability',fetch=True,query='FormattedID = XXXXXX')
      data={}
      data1={}
      p=parent.next()
      data["OID"]=p.oid
      data["FormattedID"]=p.FormattedID
      data1["PortfolioItem_SolutionCapab"]=data
     feature_name=request.args['name']
     desc=request.args['desc']
     acceptance_criteria=request.args['AcceptanceCriteria']
     plannedStartDate=request.args['PlannedStartDate']
     plannedEndDate=request.args['PlannedEndDate']
     productionDate=request.args['ProductionDate']
     notes=request.args['Notes']

     feature_data={ "Name": feature_name,"Description":desc,"AcceptanceCriteria":acceptance_criteria,"Notes":notes,"PlannedStartDate":plannedStartDate,"Parent":data1,"PlannedEndDate":plannedEndDate,"ProductionDate":productionDate}
     response = rally.create("Feature",feature_data)
     return response.details()        

    response = rally.create("Feature",feature_data)

File "C:\Python36\lib\site-packages\pyral\restapi.py", line 1024, in put raise RallyRESTAPIError(problem) pyral.restapi.RallyRESTAPIError: 422 Cannot parse object reference from "{"Parent": {"PortfolioItem_SolutionCapab": {"OID": XXXXXXXXXX, "FormattedID": "XXXX"}}}"

1

There are 1 best solutions below

2
On

Please try to pass .ref or ._ref of parent in feature_data:

feature_data={ "Name": feature_name,"Description":desc,"AcceptanceCriteria":acceptance_criteria,"Notes":notes,"PlannedStartDate":plannedStartDate,"Parent":p.ref,"PlannedEndDate":plannedEndDate,"ProductionDate":productionDate}

It should help.