2010-10-22 176 views
0

我是Restlet開發的新手,試圖添加標頭來執行HTTP請求。我想下面的代碼,卻得到了「400錯誤的請求,標題是無效」如何爲http請求添加標頭

String url = "http://xxxxx"; 
Client c = new Client(Protocol.HTTP); 

Request request = new Request(Method.GET, url); 
HashMap attributes = new HashMap(); 

attributes.put = ("DeviceID", "myDeviceID"); 
attributes.put = ("Centent-Type", "myCT"); 
attributes.put = ("User-Agent", "my user agent"); 
attributes.put = ("ClientID", "myCid"); 

request.setAttributes(attributes); 
Response r =c.handle(request); 

我使用的Restlet 2.0。 請幫忙。任何示例代碼都會很有幫助。提前致謝。 KC使用

attributes.put = ("Content-Type", "myCT"); 

Altough可能還有其他的問題,以及

回答

0

嘗試(myCT內容類型?)。沒用過的ClientID和的DeviceID頭也......但我是一個PHP的傢伙:)

+0

服務器需要包含在標題中的所有這4個字段。所以clientID和DeviceID必須在那裏,我認爲... – androidkc 2010-10-22 14:13:11

+0

好的,但你有一個錯字,它不是Centent-Type:,它是Content-Type,第二個頭文件。 – Claudiu 2010-10-22 14:38:16