0

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

Muhammad Umar
  • 349
  • 3
  • 14

1 Answers1

1

i think you just need to pass payload to send

request2.send(payload);

WhiteHat
  • 59,912
  • 7
  • 51
  • 133
  • I think this too. but I should get some message in response. At this time I am not able to get any response message eg: changed. In copper for firefox plugin. I am getting changed response but using this code I am not able to do this. – Muhammad Umar Aug 17 '16 at 15:16