1
votes

I am building an HTTP adapter to retrieve information about assets in IBM Rational Asset Manager (RAM) via its REST API. I can retrieve all assets in RAM with

https://<server>/tools/cm/ram/oslc/simpleQuery

This works fine from a browser, using RESTClient in Firefox and from my adapter when invoking with

var input = {
    method : 'get',
    returnedContentType : 'xml',
    path : 'tools/cm/ram/oslc/simpleQuery'
};

return WL.Server.invokeHttp(input);

The problem is that I get hundreds of assets in my response. I would like to filter the response from RAM by using a query like

https://<server>/tools/cm/ram/oslc/simpleQuery?query=ram_asset:community="My Community"

This works fine from a browser or RESTClient.

But when I add the query parameter to my adapter with

var input = {
    method : 'get',
    returnedContentType : 'xml',
    path : 'tools/cm/ram/oslc/simpleQuery',
    parameters : {"query" : 'ram_asset:community="My Community"'
};

return WL.Server.invokeHttp(input);

RAM returns no assets. This leads me to believe the parameters are not being added to the URI correctly. I'm suspecting it may be because the query value has special characters (':' and '=') in it. I have tried encoding with %3A and %3D with no luck.

Per suggestions from other users, I have also tried including the query parameters directly on the path with encoding but still get nothing returned from RAM:

var input = {
    method : 'get',
    returnedContentType : 'xml',
    path : 'tools/cm/ram/oslc/simpleQuery?query=ram_asset:community%3D%22My+Community%22'
};

Is it possible that the WL adapter is not handling the parameters correctly? Any ideas on how to work around it?

1
I would try sending the parameters as described in the answer to this question: stackoverflow.com/questions/25600168/…Idan Adar
Is this help full? path : "tools/cm/ram/oslc/simpleQuery?query=ram_asset:community='My Community'". in input variabledhineshsundar
If that's your path then yeah. Does it work...?Idan Adar
This definitely gave me something else to try, but unfortunately I get the same results with the parameter on the path. I updated the original post to include that test.DSchultz_mo
can you try this for your parameter:parameters : {"query" : "ram_asset:community='My Community'"Qing

1 Answers

1
votes

I finally worked out a solution. The search value needed to have double quotes - RAM would not accept single quotes. The final solution was params = {query: 'ram_asset:community="My Community"'};

If you are thinking "Isn't that what he started with?", you are right. I also had a red herring throwing me off because my community only allows authenticated users to see assets contained in it. My Firefox browser session was authenticated but the Worklight adapter was not, which explains why browser and RESTClient saw my assets and the adapter did not. There are other public communities so the adapter saw assets, just not mine. When I allowed unauthenticated users to see assets in my community, the adapter started seeing them.