PUT http请求查询

时间:2016-02-12 00:48:31

标签: networking http-headers tcp-ip arduino-uno

实际上我正在尝试将PUT请求发送到远程服务器请求成功发送到远程服务器但不幸的是该请求被认为是一个错误的请求它无法看到请求的正文我希望我的描述是明确的,这里是用Arduino编程语言发送请求的代码:

 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 个答案:

答案 0 :(得分:1)

我通过添加content-Length:10 header

解决了这个问题
function onEdit() {
  var ss = SpreadsheetApp.getActive();
  var rng = ss.getActiveRange();
  var trg = rng.offset(0, 1);
  var formula = 
    '=ARRAYFORMULA('
       + 'QUERY({'
            + 'UI!A:G,YEAR(UI!A:A),MONTH(UI!A:A),' 
            + 'TEXT(UI!A:A, "MMMM"), '
            + 'TEXT(UI!A:A, "MMM-YY"), '
            + 'REPLACE(UI!A:A,1,1000,"GRAND TOTAL")'
          + '},' 
          + '"SELECT * WHERE Col1 IS NOT NULL AND Col2 IS NOT NULL LABEL Col8 \'Year\', '
            + 'Col9 \'MonthMO#\', Col10 \'MonthMO\', Col11 \'MonthMOYR\', '
            + 'Col12 \'GRAND TOTAL\'"'
       + ')'
     + ')';
  if(rng.getValue() == 'Yes') trg.setFormula(formula);
}