Hi All,
I am trying to update CRM Quote record in Java using WEB API, but its giving me " aused by: java.io.IOException: Server returned HTTP response code: 500 for URL" Error.
Can you help me on urgent basis.
private static String UpdateQuote(String token, String accountId) throws MalformedURLException, IOException, URISyntaxException { JSONObject quote = new JSONObject(); quote.put("new_oraclequotenumber", "456"); quote.put("name","test223"); HttpURLConnection connection = null; //The URL will change in 2016 to include the API version - /api/data/v8.0/accounts URL url = new URL(RESOURCE + "/api/data/v9.1/quotes(D0BC8A5D-70FD-E811-A961-000D3A378CA2)"); // URL url = new URL(RESOURCE + "/api/data/v9.1/quotes(quotenumber='QUO-00619-B2F9D7')"); connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("X-HTTP-Method-Override", "PATCH"); connection.setRequestMethod("POST"); connection.setRequestProperty("OData-MaxVersion", "4.0"); connection.setRequestProperty("OData-Version", "4.0"); connection.setRequestProperty("Accept", "application/json"); //connection.setRequestProperty("If-Match", "*"); connection.addRequestProperty("Authorization", "Bearer " + token); connection.setUseCaches(false); connection.setRequestProperty("Content-Type", "application/json; charset=utf-8"); // connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Prefer", "return=representation"); connection.setDoOutput(true); connection.connect(); OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()); out.write(quote.toJSONString()); out.flush(); out.close(); int responseCode = connection.getResponseCode(); System.out.println("responseCode==>"+responseCode); // System.out.println("responseCode msg==>"+connection.getErrorStream()); System.out.println("responseCode msg==>"+connection.getContent()); String headerId = connection.getHeaderField("OData-EntityId"); System.out.println("headerId==>"+headerId); accountId = headerId.split("[\\(\\)]")[1]; System.out.println("accountId==>"+accountId); return accountId; }
*This post is locked for comments