0

I have a UPNP MPD server running on a Raspberry Pi connected to my home network.

I am trying to control it through the Tabris app.

fetch('http://192.168.1.6:49152/ctl/RenderingControl', {
    method: 'POST',
    headers: {
        "SOAPAction": "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume",
        "Content-Type": "text/xml; charset=utf-8"
    },
    body: '<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body><u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope>'
    }).then(function (response) {
        console.log(response.text());
    }).catch(function (error) {
        console.log('Request failed', error);
    });

This code return a 400 bad request error. However, running a curl request does work

echo '
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
   <InstanceID>0</InstanceID>
   <Channel>Master</Channel>
  </u:GetVolume>
 </s:Body>
</s:Envelope>
' | curl -v -d @- \
 -H 'SOAPAction: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"' \
 -H 'content-type: text/xml; charset="utf-8"' \
 http://192.168.1.6:49152/ctl/RenderingControl

I think it is an issue with preflight requests but not sure how to correct this.

What exactly is the way to deal with such API requests? Where in the code is the trouble?

arjun
  • 1,594
  • 16
  • 33
  • @sideshowbarker This specifically concerns running the code on Tabris JS – arjun Oct 07 '17 at 05:19
  • Then you can instead either update https://stackoverflow.com/questions/46593491/fetch-api-post-xml-request-error to make it specific to Tabris JS — and then delete this question — or else just delete that https://stackoverflow.com/questions/46593491/fetch-api-post-xml-request-error question. There’s no value in having two questions here that are describing exactly the same problem. – sideshowbarker Oct 07 '17 at 05:43
  • Please understand development has paused. But it matters, one specifies usage over web browser and the other concerning Pi and Tabris mobile app. I can't seem to find a solution to either. – arjun Oct 07 '17 at 07:01
  • If somebody looking for an answer - https://github.com/eclipsesource/tabris-js/issues/1507 – arjun Oct 13 '17 at 18:26

0 Answers0