DHIRAJ 0 Report post Posted September 26, 2018 Hi, I am trying to logon to API using the java code and check the HTTP response. This is the first time I am trying. But, I am getting the below response. {"HttpStatus":400,"ErrorMessage":"The request content-type is not supported","ErrorCode":4005} Attached the java code that I am using. Could you please help me get through this? LogonAPI.txt Share this post Link to post
Physicsman 25 Report post Posted September 26, 2018 Hi, We'll take a look and post a reply when we have a response. Thank you for your patience, PM! Share this post Link to post
DHIRAJ 0 Report post Posted September 27, 2018 Hi Physicsman, Thank you. Please let me know if I need to provide any further information. Share this post Link to post
Physicsman 25 Report post Posted September 27, 2018 Hi, Based on the error message, we're working on the basis that the request is sent with an unacceptable Content-Type. Do you use Fiddler or some other tool to view the HTTP request that is being sent? I used Postman to POST a succesful login request and with Fiddler I can view the Headers and the Raw request that was sent - see attached image. If you can screenshot your request we can then compare and see where the culprit is in your request that is leading to the error message. Many thanks! Share this post Link to post
DHIRAJ 0 Report post Posted September 28, 2018 Hi, I am not using any Fiddler. I just ran the java code from a ubuntu machine to view the HTTP message from putty itself. Share this post Link to post
Physicsman 25 Report post Posted September 28, 2018 Hi Dhiraj, We need to see what the Java code is sending in the http headers and payload in order to determine where the unacceptable content type error is coming from. You can use the free tools Wireshark or Fiddler as you prefer, to capture the requests your code is sending - in the same way as shown in the screenshots previously. Kind Regards, PM Share this post Link to post
DHIRAJ 0 Report post Posted October 1, 2018 Hi Physicsman, Apologies for the delay in responding you. The Java code is sending the below logon credential info and the headers info nameValuePairs.add(new BasicNameValuePair("Password", "XXXXXXX")); nameValuePairs.add(new BasicNameValuePair("AppVersion", "1")); nameValuePairs.add(new BasicNameValuePair("AppComments", "")); nameValuePairs.add(new BasicNameValuePair("UserName", "XXXXXXX")); nameValuePairs.add(new BasicNameValuePair("AppKey", "XXXXXXXX")); HttpPost httppost = new HttpPost("https://ciapi.cityindex.com/TradingAPI/session"); httppost.setHeader("target", "session"); httppost.setHeader("uriTemplate", "/"); httppost.setHeader("transport", "POST"); httppost.setHeader("envelope", "JSON"); httppost.setHeader("contentType", "application/json"); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8")); Also, attached the screenshot of the output from Fiddler tool Share this post Link to post
Physicsman 25 Report post Posted October 2, 2018 Many thanks! We'll take a look and reply to you when we have a response. Kind Regards, PM Share this post Link to post
DHIRAJ 0 Report post Posted October 3, 2018 Thank you. Appreciate your followup Share this post Link to post
Physicsman 25 Report post Posted October 4, 2018 Hi, It looks as though you are sending all the Service Info in the header of your call and that is likely the culprit to the 400 error response you are seeing. Please try sending just the Content-Type applicatoin/json in the header and keep your body the same and see if that works. Is your account a Live account or a demo/test account? If it is a demo/test account and you still have the problem, please send the demo account credentials to me via PM. I can make some test calls with that demo account to troubleshoot. Kind Regards, PM Share this post Link to post