2016-02-12 119 views
1

其實我試圖發送PUT請求到遠程服務器請求成功發送到遠程服務器,但不幸的是請求被認爲是一個不好的請求它看不到請求的主體我希望我的描述是明確的,這裏是代碼發送的Arduino的編程語言要求:PUT http請求查詢

Serial.println("Sending to Server: "); 
client.print("PUT /***/***/sensor/uod/1/A/1 HTTP/1.1\n"); 
Serial.print("PUT /***/***/sensor/uod/1/A/1 HTTP/1.1");          
client.print("Host: ********.koding.io\n"); 
client.print("Cache-Control: no-cache\n"); 
client.print("Content-Type: application/x-www-form-urlencoded\r\n\r\n"); 
client.print("status=1");           

一兩件事我想提一提,從服務器端我使用的是被稱爲郵差工具,並從中它成功地工作,沒有任何錯誤,實際上我已將它的http請求並將其轉換爲要發送的代碼,您可以在下面找到http請求:

PUT /***/***/sensor/uod/1/A/1 HTTP/1.1 
Host: *******.koding.io 
Cache-Control: no-cache 
Postman-Token: 8740ccb4-c0f2-a916-fd52-3089e4f3cbc9 
Content-Type: application/x-www-form-urlencoded 

status=0 

回答

1

我有解決通過添加內容長度的問題:10頭

Serial.println("Sending to Server: "); 
client.print("PUT /***/***/sensor/uod/1/A/1 HTTP/1.1\n"); 
Serial.print("PUT /***/***/sensor/uod/1/A/1 HTTP/1.1");          
client.print("Host: *********.koding.io\n"); 
client.print("Cache-Control: no-cache\n"); 
client.print("Content-Type: application/x-www-form-urlencoded\r\n"); 
client.print("Content-Length: 10\r\n\r\n"); 
client.print("status=1\r\n");