Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

WRS ODATA transaction


WRS ODATA transaction

Hi team

Do a search for 'transaction' in the WRS 2.2 manual (link 1 below). I get 8 hits. In particular, the 8 page section 'Processing HTTP Requests for OData URLs' starting at p.45 is necessary reading. I wish it contained an example. 


Clearly the transaction mechanism is intended to guard POST requests. And see 'Change sets do not support the GET operation.' on page 80. Now there is an example, thanks!


Now my question: suppose that you need to make two GET requests in succession for a report, and Windchill data can change between the requests. What algorithm can be used to ensure consistency? 


Perhaps some sort of consistency checking, followed by a retry? 


REST principles are important (link 2 below)

cheers -- Rick,-d-,2/wrs_pdf.pdf?sc_l...



It might be good practice to synchronise the GET requests - so that the second request is only made after the first is successful and so on.

For example, you might want to GET a CSRF Nonce then use the response in the next GET and then wait for a complete response before the next function.


Here's an example of a synchronous chain of requests and functions using JQuery.

.then is used to make sure the function is called only when the previous function is done, ajax and jquery handles everything else



$(document).ready(function() {
      headers: {
         'Accept': 'application/json',
   }).then(function(data) {
      var req_headers = {};
      req_headers['Content-Type'] = "application/json";
      req_headers['Accept'] = "application/json";
      req_headers['CSRF_NONCE'] = data.NonceValue;
      req_headers['Task'] = "com/ptc/windchill/enterprise/report/ExecuteReportTemplate2.xml";
      dashdata = {"Task":"com/ptc/windchill/enterprise/report/ExecuteReportTemplate2.xml","Params":[{"Value":"wt.query.template.ReportTemplate:657775537","Name":"object_ref","ValueSet":[]},{"Value":"1038 - some text","Name":"Context","ValueSet":[]}]};
         type: "POST",
         url: "http://<myWindchillHost>:80/Windchill/servlet/odata/v1/IE/InvokeIETask?%24count=true",
         headers: req_headers,
         data: JSON.stringify(dashdata)
      }).then(function(data2) {

         for (i = 0; i < data2.value[0].Elements.length; i++) {
            $('.table-content').append( "<tr><td>" + data2.value[0].Elements[i].Attributes[0].Value + "</td><td>" + data2.value[0].Elements[i].Attributes[1].Value + "</td></tr>" );




For context, this how the above request is consumed, it's a simple HTML page which lists all the names and IDs Windchill products, libraries and projects



<!DOCTYPE html>
        <title>Get All Contexts</title>
        <script src=""></script>
        <script src="getAllContexts.js"></script>

	sample usage: http://<myWindchilHost>/Windchill/netmarkets/jsp/test/getAllContexts.jsp

		<p class="GetPartStructure">

			<table class="table-content" border=1 cellspacing=0 cellpadding=3 />
					<td class="heading1">Context Name</td>
					<td class="heading2">Context ID</td>






Hi rhart

You can chain those requests in javascript but they are still separate REST GET's and POST's. Beware of doing anything stateful in the javascript. See

I was mistaken to think of transactions for this.


The subject of ODATA 'navigation' might be worth discussing. I find the doco for this really confusing, because of a lack of examples. If it works as I suspect, then it can be used for some table joins (and possibly some quite complex joins). Then I would not need multiple GET's or any transaction. It's time for a separate thread on 'navigation'! I will start one when I get a mo.