INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: How do I escape the query string for the webservice  (Read 2119 times)

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
How do I escape the query string for the webservice
« 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
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: How do I escape the query string for the webservice
« Reply #1 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?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: How do I escape the query string for the webservice
« Reply #2 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.
Logged
Matt Ashland, JRiver Media Center

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: How do I escape the query string for the webservice
« Reply #3 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
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: How do I escape the query string for the webservice
« Reply #4 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
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: How do I escape the query string for the webservice
« Reply #5 on: April 24, 2012, 02:26:55 am »

Hi Matt,

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

Regards
Paul
Logged
Pages: [1]   Go Up