soapsynologyupnpdlna

How to browse directories on Synology NAS with DLNA?


GET http://192.168.1.5:50001/desc/device.xml returns the following data:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device>
        <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>
        <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMS-1.50</dlna:X_DLNADOC>
        <friendlyName>MY-NAS</friendlyName>
        <manufacturer>Synology Inc</manufacturer>
        <manufacturerURL>http://www.synology.com/</manufacturerURL>
        <modelDescription>Synology DLNA/UPnP Media Server</modelDescription>
        <modelName>DS210j</modelName>
        <modelURL>http://www.synology.com/</modelURL>
        <serialNumber>A2G6N03829</serialNumber>
        <UDN>uuid:00113206-3dd5-0011-d53d-d53d01234567</UDN>
        <presentationURL>http://192.168.1.5:5000/</presentationURL>
        <iconList>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/tmp_icon/dmsicon120.jpg</url>
            </icon>
            <!-- 3 more icons here -->
        </iconList>
        <serviceList>
            <service>
                <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
                <SCPDURL>/connmgrSCPD.xml</SCPDURL>
                <controlURL>/ConnectionManager/control</controlURL>
                <eventSubURL>/ConnectionManager/event</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:ContentDirectory</serviceId>
                <SCPDURL>/cdsSCPD.xml</SCPDURL>
                <controlURL>/ContentDirectory/control</controlURL>
                <eventSubURL>/ContentDirectory/event</eventSubURL>
            </service>
            <service>
                <serviceType>urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1</serviceType>
                <serviceId>urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar</serviceId>
                <SCPDURL>/msrrSCPD.xml</SCPDURL>
                <eventSubURL>/MediaReceiverRegistrar/event</eventSubURL>
                <controlURL>/MediaReceiverRegistrar/control</controlURL>
            </service>
        </serviceList>
    </device>
</root>

and when I try to do the following request:

curl --location 'http://192.168.1.5:50001/ContentDirectory/control' \
--header 'SOAPAction: urn:schemas-upnp-org:service:ContentDirectory:1#Browse' \
--header 'Content-Type: text/xml; charset="utf-8"' \
--data '<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>0</ObjectID>
            <BrowseFlag>BrowseDirectChildren</BrowseFlag>
            <Filter>*</Filter>
            <StartingIndex>0</StartingIndex>
            <RequestedCount>1000</RequestedCount>
            <SortCriteria></SortCriteria>
        </u:Browse>
    </s:Body>
</s:Envelope>

I get an error code -111: Invalid Action. What is wrong here? I tried to remove #Browse from the action as well as to send only #Browse - it doesn't help.

Based on the server reply, Synology uses Linux/2.6.32.12, UPnP/1.0, Portable SDK for UPnP devices/1.6.18.


Solution

  • The problem was with missing quotes in SOAPACtion.

    I replaced --header 'SOAPAction: urn:schemas-upnp-org:service:ContentDirectory:1#Browse' with --header 'SOAPAction: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"' and it started to work as expected.