VMware Cloud Community
tuliompbarbosa
Contributor
Contributor

Problem with Method restOperation.createRequest encoding.

I am having a problem with the Method restOperation.createRequest. I created an action to make a query to the Storage Array Isilon. It is working fine when the folder that I am querying doesn't contain any spaces, if the folder contain a space the method converts the space to a "+" sign and the method does not found the folder and gives me and 404 error.
If I use the function encodeURI to convert the spaces into %20 before call restOperation.createRequest , the Method convert the "%20" to "%2520".
Here is the vRO System log:
Any help will be very appreciated.

[2017-01-17 12:41:02.097] [I] CETAD\CETAD04\
[2017-01-17 12:41:02.101] [I] O resultado do newDirPath na criação do diretório é: /ifs/DCPARMAZNA1/ZONECORP/Arquivos/CETAD/CETAD04/VPLEX e RP
[2017-01-17 12:41:02.106] [I] ISILON DTC
[2017-01-17 12:41:02.108] [I] GET Quota Operation by path
[2017-01-17 12:41:02.109] [I] /ifs/DCPARMAZNA1/ZONECORP/Arquivos/CETAD/CETAD04/VPLEX%20e%20RP
[2017-01-17 12:41:02.110] [I] Request: DynamicWrapper (Instance) : [RESTRequest]-[class com.vmware.o11n.plugin.rest.Request] -- VALUE : com.vmware.o11n.plugin.rest.Request@429d94cb
[2017-01-17 12:41:02.111] [I] Request URL: https://customerisilon.com:8080/platform/1/quota/quotas?query&path=%2Fifs%2FDCPARMAZNA1%2FZONECORP%2...
[2017-01-17 12:41:02.326] [I] Response: DynamicWrapper (Instance) : [RESTResponse]-[class com.vmware.o11n.plugin.rest.Response] -- VALUE : com.vmware.o11n.plugin.rest.Response@1f290f0c
[2017-01-17 12:41:02.328] [I] Status code: 404
[2017-01-17 12:41:02.329] [I] Content as string:
{
"errors" :
[

{
"code" : "AEC_NOT_FOUND",
"message" : "Path not found '/ifs/DCPARMAZNA1/ZONECORP/Arquivos/CETAD/CETAD04/VPLEX%20e%20RP'"
}
]
}

[2017-01-17 12:41:02.330] [E] Error in (Dynamic Script Module name : findQuotaHardSubdirectory#55) TypeError: Cannot read property "0" from undefined
[2017-01-17 12:41:02.339] [E] Workfow execution stack:


item: 'Find Quota Hard Subdirectory/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot read property "0" from undefined (Dynamic Script Module name : findQuotaHardSubdirectory#55)'
workflow: 'Find Quota Hard Subdirectory' (3ebf23df-cce1-4d7e-9974-e128e42baaef)
| 'input': name=subtenantName type=string value=\arquivos.caixa\CETAD\CETAD04\
| 'input': name=subDirName type=string value=VPLEX e RP
| 'output': name=actionResult type=string value=null
| 'no attributes'
*** End of execution stack.

3 Replies
iiliev
VMware Employee
VMware Employee

Hi,

It seems the plug-in is using java.net.URLEncoder#encode() which is not indented to encode URLs but query parameters into application/x-www-form-urlencoded format. As a result, space characters are not encoded properly as %20 but as a +.

So it looks like a bug to me. I'll open a PR to get it fixed.

BTW, which versions of vRO and REST plug-in do you use?

tuliompbarbosa
Contributor
Contributor

Hi iiliev,

I am using vRO 7.0.1.3533702 and REST plug-in 2.0.1.

The method createRequest has "Request" as return type.

I can read the Attribute fullUrl of the request, but it is read-only. If was possible to update this attribute I could use the replace function with a regex like (/\+/g,"%20") to change the query, but it is not possible.

Thanks for your help.

0 Kudos
timosteppa
Contributor
Contributor

So I pretty much have the same problem that the OP had/has.

I am running VRO 7.3 with HTTPS-REST Plug-in 2.2.2. Apparently this issue was/is fixed in the latest VRO.

This is what the release note says:

The REST API client does not encode and decode space characters correctly.

  • When querying scripting actions by their fully qualified names with the REST API client, the space characters are incorrecly encoded as %2B or a plus (+) character. As a result, the request fails with an Script module not found error message.

But I am still having this issue.

I have two workflows.

1. Authenticating the user so that I get a token to make my REST API calls

2. Using my token to perform other API calls like search for a IP address.

Here is the log that contains my current issue from the 2nd workflow:

This is what the original token looks like:

Here is the javascript. I am pretty sure that the attribute fullUrl is encoding my token to that "%253D%253D" which obviously invalidates the token.

-The only workaround I've found was to hardcode it to the restOperation template, but that defeats the purpose since tokens expire.

Do you guys happen to have a workaround or something?

Any help will be greatly appreciated!

0 Kudos