Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2796

Re: Problem in fetching X-CSRF-Token

$
0
0

Try this solution:

var destination = $.net.http.readDestination(destinationPackage,destinationName); // getCSRF Token function getCSRF() {     var request;     var response;     try {         // GET Operation on the base odata URL         request = new $.web.WebRequest($.net.http.GET, "?$format=json");         // X-CSRF-Token header will be set with value Fetch         request.headers.set("X-CSRF-Token", "Fetch");         client.request(request, destination);         response = client.getResponse();         // reading the token from response header         return response.headers.get("X-CSRF-Token").toString();     } catch (errorObj) {         $.response.setBody(JSON.stringify({             ERROR: errorObj.message         }));         return "CSRF TOKEN FETCH FAILED : " + errorObj.message;     } }

Viewing all articles
Browse latest Browse all 2796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>