使用POST创建Http请求

时间:2017-02-18 20:21:41

标签: http azure arduino azure-web-sites azure-mobile-services

void send_request(){
    //client.println("POST /tables/arduino_table HTTP/1.1");
    //client.println("Host: tremortest1.azurewebsites.net");
    //client.println("Content-Type: application/json");
    char value[]="IRTHE"; 
    Serial.print("sending ");
    Serial.println(value);

    // POST URI
    sprintf(buffer, "POST /tables/%s HTTP/1.1", table_name);
    client.println(buffer);

    // Host header
    sprintf(buffer, "Host: %s", server);
    client.println(buffer);

    // Azure Mobile Services application key
    //sprintf(buffer, "ZUMO-API-VERSION: %s", ver);
    //client.println(buffer);

    // JSON content type
    client.println("Content-Type: application/json");

    // POST body
    sprintf(buffer, "{\"value\": %d}", value);

    // Content length
    client.print("Content-Length: ");
    client.println(strlen(buffer));
}  

我正在尝试通过以下代码向Azure中的现有表添加值:

azure swagger screenshot

有人可以帮我写一下Arduino的POST请求吗?

1 个答案:

答案 0 :(得分:0)

以下是有关如何为Arduino执行HTTP POST的文章:https://forum.arduino.cc/index.php?topic=155218.0