Login  Register

Re: ZnClient and percent characters

Posted by Sven Van Caekenberghe-2 on Jun 10, 2015; 3:13pm
URL: https://forum.world.st/ZnClient-and-percent-characters-tp4831433p4831444.html


> On 10 Jun 2015, at 17:24, David <[hidden email]> wrote:
>
> El Wed, 10 Jun 2015 10:14:37 -0500
> Jimmie Houchin <[hidden email]>
> escribió:
>> Hello,
>>
>> I am attempting to use ZnClient to request data. The request requires
>> a %2C (comma) delimited string as part of the query. Below is a
>> snippet.
>>
>> znClient
>>         addPath: '/v1/instruments';
>>         queryAt: 'fields' putAll: 'displayName%2Cinstrument%2Cpip';
>>         get ;
>>         contents)
>>
>> The string  'displayName%2Cinstrument%2Cpip'
>> is being converted to  'displayName%252Cinstrument%252Cpip'
>> which causes the request to fail.
>>
>> The query needs to be
>> fields=displayName%2Cinstrument%2Cpip
>>
>> I have not found how to do this correctly.
>> Any help greatly appreciated.
>>
>> Thanks.
>>
>> Jimmie
>>
>>
>
> Maybe a silly thing, but since %2C = , ... Did you tried already to
> make itself encode that? Like
> znClient
>          addPath: '/v1/instruments';
>          queryAt: 'fields' putAll: 'displayName,instrument,pip';
>          get ;
>          contents)
>
> I suspect it is using encoding internally, that is why % is also
> encoded if you try to put it.
>
> I hope that works

Not silly and no need to suspect, but absolutely correct !

Sven