I am trying to manipulate an XML based API (HIKVision camera) from a React Native app.
fetch('http://username:password@192.168.0.83/PTZCtrl/channels/2/Continuous', {
method: 'PUT',
body: '<PTZData><pan>100</pan><tilt>0</tilt><zoom>0</zoom></PTZData>',
headers: {
'Content-type': 'text/xml'
}
})
.then(res=>res.text())
.then(res=>console.log(res))
.catch(e=>{
console.log(e);
})
This is the error I recieve after running it.
Network request failed - node_modules\react-native\node_modules\whatwg-fetch\fetch.js:441:29 in onerror - node_modules\event-target-shim\lib\event-target.js:172:43 in dispatchEvent - ... 9 more stack frames from framework internals
What I want is to send XML to the server. I have been able to successfully manipulate the API using this curl command. TEST_PTZ.xml contains the same xml string in the above code.
curl -X PUT -T TEST_PTZ.xml --trace-ascii curl.trace http://username@password@192.168.0.83/PTZCtrl/channels/1/Continuous
I have narrowed it down to not being a CORS issue. I am open to a fix or other suggestions.