Solved
Problem getting CSRF_NONCE value (HTTP 400)
Hello,
I am stuck and need suggestions what to do. I am trying to get CSRF_NONCE value, using rest query with java api (I working with Windchill 12.0 server). But what ever I do I get HTTP code 400.
Tried queries were: https://myServer/Windchill/servlet/odata/PTC/GetCSRFToken()
My code is:
URL url = new URL ("https://myServer/Windchill/servlet/odata/PTC/GetCSRFToken()"); HttpURLConnection conn = (HttpURLConnection) obj.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "Basic " + authString); //authstring is Base64 encoded conn.connect(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); conn.disconnect();
------------
I am pretty sure that code is ok because if I try query "https://myServer/Windchill//servlet/rest/objects?$select=number&typeId=wt.part.WTPart"
I am getting right result. Also both queries return right result if I use Firefox or Postman instead of my
code.
If anybody have suggestions what is wrong or what to do I will be grateful for help.
Best reagads,
Nenad

