Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Fork of HTTPClient_HelloWorld by
Revision 3:64b3aa4b90f1, committed 2015-03-18
- Comitter:
- terrence
- Date:
- Wed Mar 18 11:23:08 2015 +0000
- Parent:
- 2:270e2d0bb85a
- Commit message:
- Can't set headers.
Changed in this revision
--- a/EthernetInterface.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/EthernetInterface.lib Wed Mar 18 11:23:08 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa +http://mbed.org/users/mbed_official/code/EthernetInterface/#65b0d840274c
--- a/HTTPClient.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/HTTPClient.lib Wed Mar 18 11:23:08 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de +http://developer.mbed.org/users/MACRUM/code/HTTPClient/#3c7789c521df
--- a/main.cpp Thu Aug 30 15:42:06 2012 +0000
+++ b/main.cpp Wed Mar 18 11:23:08 2015 +0000
@@ -1,79 +1,56 @@
+//find httpclient-ssl by mason.
#include "mbed.h"
#include "EthernetInterface.h"
#include "HTTPClient.h"
-
+
EthernetInterface eth;
HTTPClient http;
char str[512];
+char json[125];
int main()
{
- eth.init(); //Use DHCP
+ // HTTPText text("text/html", bufsiz);
+ //HttpText(const string& encoding = "text/html")
+
+ // printf("(Buffer size of a HTTPText : %d)\n", bufsiz);
+ // HTTPResult r = client.get(url, &text);
+ //'{\"Email\":\"tps@tps.com\",\"PhoneNumber\":\"512-244-6688\",\"RowKey\":\"20141122:105633\",\"PartitionKey\":\"spencer\"}'
+ //strcpy(str, "This is a PUT test!");
+ //HTTPText outText(str);
- eth.connect();
+
- //GET data
- printf("\nTrying to fetch page...\n");
- int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
+ eth.init(); //Use DHCP
+ eth.connect();
+ printf("IP Address is %s\n", eth.getIPAddress());
+
+ //POST data
+ HTTPMap map;
+ map.put("value", "World");
+
+ http.setDataType("Content-Type","application/x-www-form-urlencoded");
+ http.setRequestHeader("Content-Length",210);
+ string data = "={\"PartitionKey\":\"LSlaughter\",\"RowKey\":\"20150318:111818\",\"SubLocationID\":\"600W8thOffice\"}";
+ HTTPText jsonText("value");
+ jsonText.set(data);
+ printf("\nTrying to post data...\r\n");
+
+ int ret = http.post("http://tpswebapi1.azurewebsites.net/api/values", jsonText, null);
+
if (!ret)
{
- printf("Page fetched successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
+ printf("Executed POST successfully - read %d characters\r\n", strlen(str));
+ printf("Result: %s\r\n", str);
}
else
{
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
- //POST data
- HTTPMap map;
- HTTPText inText(str, 512);
- map.put("Hello", "World");
- map.put("test", "1234");
- printf("\nTrying to post data...\n");
- ret = http.post("http://httpbin.org/post", map, &inText);
- if (!ret)
- {
- printf("Executed POST successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ printf("Error - ret = %d - HTTP return code = %d\r\n", ret, http.getHTTPResponseCode());
}
- //PUT data
- strcpy(str, "This is a PUT test!");
- HTTPText outText(str);
- //HTTPText inText(str, 512);
- printf("\nTrying to put resource...\n");
- ret = http.put("http://httpbin.org/put", outText, &inText);
- if (!ret)
- {
- printf("Executed PUT successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
- //DELETE data
- //HTTPText inText(str, 512);
- printf("\nTrying to delete resource...\n");
- ret = http.del("http://httpbin.org/delete", &inText);
- if (!ret)
- {
- printf("Executed DELETE successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
+
eth.disconnect();
-
+
while(1) {
}
-}
+}
\ No newline at end of file
--- a/mbed-rtos.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed-rtos.lib Wed Mar 18 11:23:08 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90 +http://mbed.org/users/mbed_official/code/mbed-rtos/#63988a2238f7
--- a/mbed.bld Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed.bld Wed Mar 18 11:23:08 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf \ No newline at end of file
