My UPNP Media Browser app is progressing quite nicely now, but I have come across an error caused by sending a HTTP request that is not formatted correctly. The error I receive is "Success=False Error:Bad Request".
I have determined that this is caused by an amplisand in the item I am trying to browse. The code below shows the result of a browse request, the data I extract using an XOM parser and the subsequent browse request...
If I modify the ObjectID and replace "&" with "&" which is the correct HTML entity it works fine.
Now for my question... I have tried to use the StringUtils library to encode the ObjectID but that didn't work as the URLEncode function is different to what I require.
Is there a way to format my string such as...
This doesn't work and so at pressent I am using...
Which works but only covers the amplisand entity, I'd like to cover all eventualities if possible?
Thanks,
RandomCoder
I have determined that this is caused by an amplisand in the item I am trying to browse. The code below shows the result of a browse request, the data I extract using an XOM parser and the subsequent browse request...
HTML:
##### BROWSE RESULTS (RAW DATA) #####
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result>
<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/">
<container id="musicdb://artists/635/23/?albumartistsonly=true&amp;artistid=635"
parentID="musicdb://artists/635/?albumartistsonly=true"
restricted="1"
searchable="0">
<dc:title>Free All Angels</dc:title>
<dc:creator>Unknown</dc:creator>
<upnp:artist role="Performer">Ash</upnp:artist>
<upnp:artist role="AlbumArtist">Ash</upnp:artist>
<upnp:album>Free All Angels</upnp:album>
<upnp:genre>Unknown</upnp:genre>
<upnp:albumArtURI dlna:profileID="JPEG_TN">http://192.168.0.100:1309/%25/C72C9D9A515FA434C903C17A8E0ACBA6/Folder.JPG</upnp:albumArtURI>
<res protocolInfo="xbmc.org:*:fanart:*">http://192.168.0.100:1309/%25/032E881D8D061734E77C697FC2E8BBD9/ash-4dd6ac34e27b0.jpg</res>
<upnp:class>object.container.album.musicAlbum</upnp:class>
</container>
</DIDL-Lite>
</Result>
<NumberReturned>1</NumberReturned>
<TotalMatches>1</TotalMatches>
<UpdateID>0</UpdateID>
</u:BrowseResponse>
</s:Body>
</s:Envelope
Container-->[id=musicdb://artists/635/23/?albumartistsonly=true&artistid=635]
[title=Free All Angels]
[class=object.container.album.musicAlbum]
[resolution=]
[location=http://192.168.0.100:1309/%25/032E881D8D061734E77C697FC2E8BBD9/ash-4dd6ac34e27b0.jpg]
##### SEND BROWSE REQUEST #####
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<ObjectID>musicdb://artists/635/23/?albumartistsonly=true&artistid=635</ObjectID>
<BrowseFlag>BrowseDirectChildren</BrowseFlag>
<Filter>*</Filter>
<StartingIndex>0</StartingIndex>
<RequestedCount>100</RequestedCount>
<SortCriteria></SortCriteria>
</u:Browse>
</s:Body>
</s:Envelope>
BAD REQUEST!
Now for my question... I have tried to use the StringUtils library to encode the ObjectID but that didn't work as the URLEncode function is different to what I require.
Is there a way to format my string such as...
B4X:
Dim su As StringUtils
browseID = su.EncodeUrl(objectID, "UTF8")
B4X:
browseID = objectID.Replace("&", "&")
Thanks,
RandomCoder