INTERACT FORUM

Windows => Third Party Plug-ins, Programs, and Skins => Topic started by: PaulSinnema on April 15, 2012, 01:14:17 am

Title: How do I escape the query string for the webservice
Post by: PaulSinnema on April 15, 2012, 01:14:17 am
Hi,

I'm expanding MC Remote with an artist and album list but got a bit of a problem. I use the /Library/Values url to get the artists like so:

Code: [Select]
http://speedy:52199/MCWS/v1/Library/Values?Field=Artist
This returns an XML with all the artist names:

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <Response Status="OK">
  <Item>16 Horsepower</Item>
  <Item>A&HA</Item>
  <Item>A.O.S.</Item>


To be able to display an image for the artist I retrieve the first song of this artist. As a test I changed the name 'A HA' to 'A&HA'. This will cause a url problem because the ampesand is used as webquery separator.

I've used the following code to Escape the ampesand

Code: [Select]
parameters.Add("Query", "[Artist]=" + Uri.EscapeDataString(artistName));
The result is:

Code: [Select]
http://Speedy:52199/MCWS/v1/Files/Search?Action=serialize&Query=[Artist]=A%26HA&Fields=Key&Zone=0&ZoneType=ID
where the ampesand is translated to '%26'. This however return all keys in the library which of course not is what I want.

I there a way to solve this problem?

Regards
Paul
Title: Re: How do I escape the query string for the webservice
Post by: PaulSinnema on April 18, 2012, 09:54:04 am
The problem is even worse. Any spaces in artist names cause problems. The querystring does not allow strings in it. The escaped value is correct. I guess the Webservice simply does not do an unescape of the query string. Am I correct?
Title: Re: How do I escape the query string for the webservice
Post by: Matt on April 18, 2012, 10:14:55 am
We were using recursive dehexification of the URL parameters, and this made it impossible to use a literal &.

Look for a fix next build.
Title: Re: How do I escape the query string for the webservice
Post by: PaulSinnema on April 19, 2012, 04:28:06 am
Thanks Matt,

I can keep the escaping that I use now or do I need to do something else here?

Regards
Paul
Title: Re: How do I escape the query string for the webservice
Post by: PaulSinnema on April 24, 2012, 02:16:13 am
We were using recursive dehexification of the URL parameters, and this made it impossible to use a literal &.

Look for a fix next build.

Hi Matt,

Take a look at this post please. I had made a mistake in the parameters routine and solved something. http://yabb.jriver.com/interact/index.php?topic=71697.msg484496#msg484496

Regards
Paul
Title: Re: How do I escape the query string for the webservice
Post by: PaulSinnema on April 24, 2012, 02:26:55 am
Hi Matt,

No need to look any further. This also solves this problem.

Regards
Paul