Highlighted
Super Contributor.
Super Contributor.
717 views

REST Driver adding an unwanted forward slash

Jump to solution

I am trying to submit a match query to a REST API.  It should look like this:

https://XXXX.jamacloud.com/rest/latest/users?username=R12345678

but the driver is adding a forward slash and it looks like this:

https://XXXX.jamacloud.com/rest/latest/users?username=/R12345678

As you can see below, the forward slash is not present in the association value .  Has anyone else encountered this and figured it out?

</source>
<input>
<driver-operation-data class-name="users" command="query" event-id="0">
<request>
<url-token association="R12345678" filter="?search-attr=username+eq+%27R12345678%27&amp;read-attr="/>
<header content-type="application/json"/>
{"scope":"subtree","event-id":"0","class-name":"users","search-class":["users"],"search-attr":[{"username":"R12345678"}],"read-attr":[""]}
</request>
</driver-operation-data>
</input>
</nds>
[06/26/19 12:25:01.125]:JAMA ST: JAMA: sub-execute
[06/26/19 12:25:01.126]:JAMA ST: JAMA: queryHandler
[06/26/19 12:25:01.126]:JAMA ST: JAMA: queryHandler: class-name == 'users'
[06/26/19 12:25:01.126]:JAMA ST: JAMA: Query: preparing GET to https://XXXX.jamacloud.com/rest/latest/users?username=/R12345678
[06/26/19 12:25:01.127]:JAMA ST: JAMA: Setting the following HTTP request properties:
Authorization:
[06/26/19 12:25:01.127]:JAMA ST: JAMA: content-type:application/json
[06/26/19 12:26:00.699]:JAMA PT:JAMA: poll
[06/26/19 12:26:00.699]:JAMA PT:Receiving DOM document from application.
[06/26/19 12:26:00.699]:JAMA PT:


Peggy Townsend
Novacoast
Labels (1)
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert
Hi,
Try using another URL parameter than "association". IIRC that parameter will always be inserted with a / prefix.
--
Norbert

View solution in original post

10 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Is it possibly this line:

<url-token association="R12345678" filter="?search-attr=username+eq+%27R12345678%27&amp;read-attr="/>

 

The %27?  But nope, that is a single quote URL escaped.  Is it possible the read-attr of / which should be like an XML null is inserting?

0 Likes
Highlighted
Super Contributor.
Super Contributor.

I spent some time manipulating the xml to remove the read-attr from the filter and the value but the forward slash remains.  See below.

<input>
<driver-operation-data class-name="users" command="query" event-id="0">
<request>
<header content-type="application/json"/>
{"scope":"subtree","event-id":"0","class-name":"users","search-class":"users","search-attr":"username":"R12345678"}
<url-token association="R12345678" filter="?search-attr=username+eq+%27R12345678%27"/>
</request>
</driver-operation-data>
</input>
</nds>
[06/27/19 16:42:35.981]:JAMA ST: JAMA: sub-execute
[06/27/19 16:42:35.981]:JAMA ST: JAMA: queryHandler
[06/27/19 16:42:35.982]:JAMA ST: JAMA: queryHandler: class-name == 'users'
[06/27/19 16:42:35.982]:JAMA ST: JAMA: Query: preparing GET to https://xxx.jamacloud.com/rest/latest/users?username=/R12345678
[06/27/19 16:42:35.982]:JAMA ST: JAMA: Setting the following HTTP request properties:
Authorization:
[06/27/19 16:42:35.983]:JAMA ST: JAMA: content-type:application/json

 


Peggy Townsend
Novacoast
Highlighted
Knowledge Partner
Knowledge Partner

Stupid idea. How high have you kicked the RL or engine (depending on where it is running) trace level?  Try 25 or 100 or somesuch and see if anything hint like emerges.

 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Increased trace did nothing.  I'm opening a ticket.  I'll report back.  I'm surprised no one else is reporting this issue.


Peggy Townsend
Novacoast
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Resolved.  It turns out that the REST API doesn't care if the forward slash is there or not.  If I query for users?username=ptown or users?username=/ptown the result is the same.  My user is found by both queries.  I discovered this by running the query both ways using postman.  


Peggy Townsend
Novacoast
0 Likes
Highlighted
Super Contributor.
Super Contributor.

I am working on another REST driver using a different API.  This API does not ignore the forward slash.  The result is user not found. 

The driver creates this query  with unwanted forward slash.

Example:  

http://glm-beta.herokuapp.com/api/v1/managed_users?email=/**PERSONAL INFORMATION REMOVED**

instead of

http://glm-beta.herokuapp.com/api/v1/managed_users?email=**PERSONAL INFORMATION REMOVED**

 

Here is the trace snippet

<input>
<driver-operation-data class-name="managed_users" command="query" event-id="0">
<request>
<url-token association="**PERSONAL INFORMATION REMOVED**" filter="?search-attr=email+eq+%27testy.testerson2%40networks.com%27&amp;read-attr="/>
<header content-type="application/json"/>
<value>{"scope":"subtree","event-id":"0","class-name":"managed_users","search-class":["managed_users"],"search-attr":[{"email":"**PERSONAL INFORMATION REMOVED**"}],"read-at
tr":[""]}</value>
</request>
</driver-operation-data>
</input>
</nds>
[05/06/20 16:45:38.348]:glm ST: GLM: sub-execute
[05/06/20 16:45:38.348]:glm ST: GLM: queryHandler
[05/06/20 16:45:38.348]:glm ST: GLM: queryHandler: class-name == 'managed_users'
[05/06/20 16:45:38.349]:glm ST: GLM: Query: preparing GET to https://glm-beta.herokuapp.com/api/v1/managed_users?email=/**PERSONAL INFORMATION REMOVED**
[05/06/20 16:45:38.349]:glm ST: GLM: Resetting headers
[05/06/20 16:45:38.349]:glm ST: GLM: Setting the following HTTP request properties:
Authorization: <content suppressed>
[05/06/20 16:45:38.360]:glm ST: GLM: content-type:application/json
[05/06/20 16:45:38.360]:glm ST: GLM: X-User-Email:glm-service@1.local
[05/06/20 16:45:38.360]:glm ST: GLM: X-User-Token:fxCRRdWqSD5WHn5d3DH9
[05/06/20 16:45:38.360]:glm ST: GLM: Annonymous login
[05/06/20 16:45:38.360]:glm ST: GLM: Did a HTTP GET with 0 bytes of data to https://glm-beta.herokuapp.com/api/v1/managed_users?email=/**PERSONAL INFORMATION REMOVED**
[05/06/20 16:45:42.570]:glm ST: GLM: Response code and message: 404 Not Found
[05/06/20 16:45:42.570]:glm ST: SubscriptionShim.execute() returned:


Peggy Townsend
Novacoast
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Peggy,

which paths and methods have you specified in driver parameters / subscriber / resource for the managed_users class?

 

 

--
Norbert
0 Likes
Highlighted
Super Contributor.
Super Contributor.

My issue is with the GET method.  I have one query handler configured for GET:

managed_users?email=<association>

I also have a POST, PUT and DELETE configured and working. 

 

 


Peggy Townsend
Novacoast
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert
Hi,
Try using another URL parameter than "association". IIRC that parameter will always be inserted with a / prefix.
--
Norbert

View solution in original post

Highlighted
Super Contributor.
Super Contributor.

That was it.  Email was the association but is also an attribute.  When I switched from <association> to <email> the problem was fixed.  Thanks for the prompt reply and a very nice solutionn.


Peggy Townsend
Novacoast
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.