I want to generate PUT request. I have successfully generated GET request to get data from CoRE resource directory but I am unable to generate PUT request with xml payload. Your help would be highly appreciated. Following is my code
function PutReq(){
setTimeout(function() {
var request2 = new CoAPRequest();
var payload = '<?xml version="1.0" encoding="UTF-8"?><te:lightingSceneRootType xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"xmlns:te="http://www.baas-itea3.eu/temperature"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><lightingSceneName>Off</lightingSceneName></te:lightingSceneRootType>';
alert(payload);
request2.open('PUT', wLink , true);
request2.onload = function () {
var res2 = request2.responseText;
alert(res2);
};
request2.send();
}, 2000);
}
wLink is the variable in which I have put the url. I am using this delay function because I am taking the link from the first function and I need to run this request with delay so that I can get the response from first function. The problem is, how to send payload using put request. Please guide me. Thanks