RESTful Services
 

RESTful Services

12 posts, 0 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    20 Sep 2022
    Link to this post
    We have a BE with the following RestAddress.

    @RestAddress (type="collection", address="/PurchaseOrder", tables="ePurchaseOrder,ePoLine", id="OrderNum",
                  fields="ePurchaseOrder.*,ePoLine.*", canRead="true", canUpdate="true", canDelete="false", canCreate="true",
                  links="PoLine:/PurchaseOrder/~{OrderNum}/PoLine"

    This works great for most of what we need. However, we need to pass a query of Stat LE 1 OR Stat GE 5 but this does not appear to be supported by REST. 

    When we use http://192.168.168.68:8940/OspreyHostBackend/web/Entities/PurchaseOrder?Stat<=2&Stat>=5

    We get the following logged in PASOE

    Client-Query: for each ePurchaseOrder WHERE ePurchaseOrder.Stat <= "2" AND ePurchaseOrder.Stat >= "5"

    What would be the best way to handle this? We have tried creating a REST METHOD where we can define our own query and return back the PDS. However, the response is different than that of the RestAddress.



  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    20 Sep 2022 in reply to Roger Blanchard
    Link to this post
    Hi Roger,

    OR is indeed difficult - as we have not real way in the URL to provide different operators than AND (&).

    Best I can think of right now would be a query string like this

    ?stat<=2&operator=or&stat>=5 

    But that would require an enhancement request and I'm not sure we can work on this in September still.
  3. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    20 Sep 2022 in reply to Mike Fechner
    Link to this post
    Hi Mike,

    I hope you are well...PUG was good!!

    Is there a way to pass a string like filter="Stat<=2 OR Stat >=5" and then grab that on the backend and manipulate the query?
  4. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    20 Sep 2022 in reply to Roger Blanchard
    Link to this post
    You can "abuse" the quick search.

    q="Stat<=2 or Stat>=5".

    The Business Entity needs to implement the ISupportsQuickSearch interface and you need to code the "QuickSearch" named query.  
  5. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    20 Sep 2022 in reply to Mike Fechner
    Link to this post
    PUG was fun by the way. We really need to get a PUG conference in the US organized soon! 
  6. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    20 Sep 2022 in reply to Mike Fechner
    Link to this post
    Let me see how bad I can abuse it...thanks for the info
  7. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    21 Sep 2022 in reply to Mike Fechner
    Link to this post
    Hello Mike,

    I am going to look at this today. Can you give me a hint on where to code the quick search?

    I have added the ISupportsQuickSearch.

    Do I just check for the named query in FetchData of the BE?
  8. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    21 Sep 2022 in reply to Roger Blanchard
    Link to this post
    Yes - FetchData is usually the place to deal with Named Queries. I would however implement it in the Data Access class and not the Business Entity as it's query manipulation and not business logic.
  9. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    21 Sep 2022 in reply to Mike Fechner
    Link to this post
    Thanks Mike!!
  10. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    21 Sep 2022 in reply to Mike Fechner
    Link to this post
    Hello Mike.

    I have added the -q="Stat<=2 or Stat>=5" 

    http://192.168.168.68:8940/OspreyHostBackend/web/Entities/PurchaseOrder?q="Stat<=2 or Stat>=5"

    In the DA class I do see a named query "QuickSearch". However, if log the value of the parameter to PASOE the value only has "Stat< 

    oCharacter = CAST (oQuickSearch:Parameters:GetItem(1):VALUE,CharacterHolder).

    MESSAGE "oCharacter:Value=" oCharacter:Value
    VIEW-AS ALERT-BOX.
  11. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    21 Sep 2022 in reply to Roger Blanchard
    Link to this post
    The following will work

    http://192.168.168.68:8940/OspreyHostBackend/web/Entities/PurchaseOrder?q="Stat LE 2 or Stat GE 5"


    It looks like Consultingwerk.OERA.RestResource.RestEntitiesWebHandler:FetchDataRequestFromRestRequest does not like the = in the quick search?

    I think I am good...thanks for the guidance!!
  12. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    21 Sep 2022 in reply to Roger Blanchard
    Link to this post
    I would expect that you need to URL encode space and equal signs etc.

    https://meyerweb.com/eric/tools/dencoder/

    Otherwise the = sign is treated like a separator of arguments. 
12 posts, 0 answered