2012-08-29 20 views
7

Üretimini hazır ve mobil uygulamalar uygulamasının bir parçası olarak kullanılan Phil Sturgeons cool Restful API framework for codeigniter'u kullanarak API'mızı oluşturduk. JavaRestful API codeigniter - JAVA issue

yılında
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() durum kodu alamadı API kullanarak ve bozuk bir istisna döndüğünde

Bir sorunumuz var. API sunucumuz NGINX. Üstbilgi alanları düzgün ayarlanmadığında, MalformedException atılır.

+1

Döndükten sonra yayınlayabilir misiniz? – Broncha

+0

Bunu işe aldınız mı? – seangates

+0

[CI] (http://codeigniter.com) gerekli değilse [jabsorb] (http://code.google.com/p/jabsorb/) adresine bir şans verebilirsiniz. – quantme

cevap

1

Lütfen farklı başlıklar ve farklı kullanıcı aracıları ile kontrol edin. httpConnection.setDoOutput (true) kullanılarak deneniyor;