Recovery API - JAVA Problem

We built our API using the Phil Sturgeons cool Restful API framework for codeigniter , which is production-ready and used as part of a mobile application implementation.

We have a problem when using the API in Java

httpConnection = (HttpConnection) Connector.open(url, Connector.READ, true); // Set content type by given parameter...... httpConnection.setRequestProperty("Accept", contentType); httpConnection.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/FCLDC-1.0"); httpConnection.setRequestProperty("Content-Type", contentType); httpConnection.setRequestProperty("TK-API-KEY", UrlFactory.TK_API_KEY); // httpConnection.setRequestProperty("Model", // StyleUtil.getDeviceModel()); if (httpConnection.getResponseCode() == 302) { String redirectUrl = httpConnection.getHeaderField("Location"); httpConnection = (HttpConnection) Connector.open(redirectUrl, Connector.READ_WRITE, true); } if (httpConnection.getResponseCode() == HttpConnection.HTTP_OK) { io = httpConnection.openInputStream(); int ch; while ((ch = io.read()) != -1) { bo.write(ch); } } 

httpConnection.getResponseCode() cannot receive a status code and returns an invalid exception. Our API server is NGINX.

+7
source share
1 answer

A malformedException is thrown if the header fields are not set properly. Please check with various headers as well as with various user agents. Trying to use httpConnection.setDoOutput (true);

+1
source

All Articles