Rally Software

Expand all | Collapse all

Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

Jump to Best Answer
  • 1.  Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 01-19-2018 01:10 PM

    Team, 

     

    Trying to make a query to Rally from Salesforce Apex Class. But getting the following error. But this works when I directly hit the URL in the Browser. Please advise.

     

    {Errors=(Could not parse: Cannot parse expression "https://rally1.rallydev.com/slm/webservice/v2.0/defect?query=((Owner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=RankOwner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=Rank" as a query), PageSize=0, Results=(), StartIndex=0, TotalResultCount=0, Warnings=(), _rallyAPIMajor=2, _rallyAPIMinor=0}

     

     

    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
    req.setEndpoint('https://rally1.rallydev.com/slm/webservice/v2.0/defect?query=((Owner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=RankOwner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=Rank')
    ');
    req.setMethod('GET');
    req.setHeader('Content-Type', 'application/json');
    req.setHeader('ZSESSIONID','*********');
    Http http = new Http();
    res = http.send(req);
    System.debug(res.getBody());

     

    Thanks



  • 2.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression
    Best Answer

    Posted 01-22-2018 03:59 AM

    Karthik,

     

    I am not sure if it is a copy paste error or if it is what your program is doing, but the URL looks very strange.  It looks like an additional (( Owner.Name = username@email.com ) AND ( State != Completed ))&order=Rank is being added.  Could your code being adding too much to the string?

     

    Your query (addition in bold):

     

    https://rally1.rallydev.com/slm/webservice/v2.0/defect?query=((Owner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=RankOwner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=RankOwner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=Rank

     

    If you ensure the URL for the query in your code is:

     

    https://rally1.rallydev.com/slm/webservice/v2.0/defect?query=((Owner.Name%20=%20username@email.com)%20and%20(State%20!=%20Completed))&order=Rank

     

    Does that work?

     

    Michael



  • 3.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 01-22-2018 01:55 PM

    Thanks Mike for your support, it works. 



  • 4.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 01-23-2018 12:52 PM

    Terrific!  I am glad that was it!

     

    Michael



  • 5.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 01-31-2018 04:53 PM

    Hi Everyone,

    I've been searching in the Community and ran across this post.  I'm relatively new to Rally and am looking into 'Query Results as RSS 2.0 Feeds' in the API Help documentation.  I have a simple query similar to the example:

    20jhehr@rallydev.com)%20and%20(State%20!=%20Completed))&order=Rank" rel="nofollow" style="color: #29beff; background-color: #ffffff; border-bottom: 0px #e25401; text-decoration: underline; font-size: 12.864px" target="_blank">https://rally1.rallydev.com/slm/webservice/v2.0/rss/task?title=My Tasks&query=((Owner.Name = jhehr@rallydev.com) and (State != Completed))&order=Rank

     

    When I run it in the URL, I do get back results, however, it's in a format that is unreadable.  How do I parse all of the code out of the results to get it in a readable format?

    Thanks in advance,

    Carol



  • 6.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-01-2018 03:20 AM

    CarolBrumfield1350591,

     

    Are you putting the URL into an RSS feed reader or simply into a browser?  Here is what I see pasting the URL in Chrome:

     

    XML Chrome

     

    The RSS Feed XML is returned and formatted as such.

     

    If I add the URL to an RSS Feed Reader Extension in Chrome, here is the result:

     

    Feed Reader

     

    If you are looking to do something else with the information would you provide more about what you are trying to do or expecting?

     

    Michael



  • 7.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-01-2018 12:02 PM

    Thank you Michael, that helped a lot!  I added the RSS Feed Reader in Chrome, and now I get my tasks:

     

     

    But when I click on one of the tasks, it shows all the code again that is unreadable.  Is this expected behavior, or is there a way to get back to the task in Rally once I click on it?

     

    Thanks so much for your help!

    Carol Ann



  • 8.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-01-2018 12:49 PM

    One more question:  When I try to input this query in the Google RSS Feed to find data in a custom field:

    https://rally1.rallydev.com/slm/webservice/v2.0/PortfolioItem?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111&query=(c_EPMSID != "")&fetch=c_EPMSID&
    start=1&pagesize=200

     

    I get:  "No feeds were found for that search".

     

     

    Is there anything I can do to get some results returned?

     

    Thanks again,

    Carol Ann



  • 9.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-01-2018 12:52 PM

    One more question:  When I try to input this query in the Google RSS Feed to find data in a custom field:

    https://rally1.rallydev.com/slm/webservice/v2.0/PortfolioItem?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111&query=(c_EPMSID != "")&fetch=c_EPMSID&
    start=1&pagesize=200

     

    I get:  "No feeds were found for that search".

     

     

    Is there anything I can do to get some results returned?

     

    Thanks again,

    Carol Ann

     



  • 10.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 06:54 AM

    Carol Ann,


    For the query issue, your URL it is missing the 'rss' portion.  It should look like this (note /rss before the object type):

     

    https://rally1.rallydev.com/slm/webservice/v2.0/rss/PortfolioItem?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111&query=( c_EPMSID != "" )&fetch=c_EPMSID&start=1&pagesize=200

     

    I don't think the 'fetch' parameter works in the rss feed endpoint.  See this new post from yesterday:

    Is it possible to fetch the Formatted ID when using an RSS Query Feed? 

     

    I don't have an answer for that yet, but will check on it with Engineering.

     

    As for the other issue, it looks like the link that is sent to the item is the link to the Web Services API version of the Artifact.  Honestly, I don't know if that is by design or not.  I'll check with the Product Owners and see what they say.

     

    Michael



  • 11.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 07:05 AM

    That is awesome, thanks so much for your help Michael!

    Carol Ann



  • 12.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 07:23 AM

    One more question – is it possible to use SQL to query the database to get the answers I need?

     

    Thanks again,

    Carol Ann



  • 13.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 08:47 AM

    Carol Ann,

     

    What exactly are you trying to accomplish?  Do you have a need for information outside of Agile Central?  You can certainly get this information via a Custom List or Filtered view in Agile Central.  If I had a bit more information about what you are trying to do, maybe I can suggest an alternative.

     

    Michael



  • 14.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 08:53 AM

    ok!  There are actually 2 things I would like to do.  1) have my Agile Central tasks shown as an RSS feed that I can click on and it would take me directly to the task in Agile Central.  2) I would like a report of users, actual hours spent per User Story, and also include data from 2 custom fields.  #2 is the one that I was thinking could be done by SQL.  I’m not sure if it could be done with a Custom List.

     

    Thanks for your help,

    Carol Ann



  • 15.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 11:35 AM

     Your thread inspired my question, CarolBrumfield1350591 Is it possible to fetch the Formatted ID when using an RSS Query Feed?  I didn't want to hijack or distract from your thread, so i gave it a life of it's own.  It looks as though we may think along the same lines!   

     

    I love the option of having RSS feeds, but my team is so Formatted ID oriented that it turns into a handicap without it.

     

    Thank you for your help--> bulmi01 !



  • 16.  Re: Rally Webservices Rest API Query Error - Could not parse: Cannot parse expression

    Posted 02-02-2018 11:37 AM

    Yeah, great!  I’d like to learn the answer to that too!