Hi,
Can you please post an example program for sending JSON data through HTTP Post request, using GRPS ?
Example of HTTP Post request for sending json data
-
- Posts: 27967
- Joined: Mon Sep 28, 2009 1:06 pm
Re: Example of HTTP Post request for sending json data
Hi,
Here is the example to make a HTTP POST request, we don't use the JSON format to send data so we dont know if it will work.
http://www.libelium.com/development/was ... with-post/
Also you can try opening a TCP connection.
http://www.libelium.com/development/was ... onnection/
Regards
Here is the example to make a HTTP POST request, we don't use the JSON format to send data so we dont know if it will work.
http://www.libelium.com/development/was ... with-post/
Also you can try opening a TCP connection.
http://www.libelium.com/development/was ... onnection/
Regards
Re: Example of HTTP Post request for sending json data
Nevermind, I programmed the server to work with www-formurlencoded data. Thanks anyways! 

-
- Posts: 27967
- Joined: Mon Sep 28, 2009 1:06 pm
Re: Example of HTTP Post request for sending json data
You're welcome!
-
- Posts: 2
- Joined: Fri Aug 23, 2019 9:47 pm
- Company: Unicauca
Re: Example of HTTP Post request for sending json data
I made this code for sending in json format
void SendHttpData(){
//////////////////////////////////////////////////
// 1. Switch ON
//////////////////////////////////////////////////
error = WIFI_PRO.ON(socket);
if (error != 0)
{
USB.println(F("1. WiFi did not initialize correctly"));
ErrCount++;
}
else
{
// 2. Set url
error = WIFI_PRO.setURL( type, host, port, url );
if (error == 0)
{ USB.println(F("2. setURL OK"));
}
else
{
USB.println(F("2. Error calling 'setURL' function"));
WIFI_PRO.printErrorCode();
}
//Set content Type
error = WIFI_PRO.setContentType(ContentType);
// check response
if (error == 0)
{
USB.println(F("2. setContentType OK"));
}
else
{
USB.println(F("2. Error calling 'setContentType' function"));
WIFI_PRO.printErrorCode();
}
//////////////////////////////////////////////////
// 3. Join AP
//////////////////////////////////////////////////
// check connectivity
status = WIFI_PRO.isConnected();
// Check if module is connected
if (status == true)
{
USB.println(F("3. WiFi is connected OK"));
USB.println(body);
////////////////////////////////////////////////
// 3.1. http request
////////////////////////////////////////////////
error = WIFI_PRO.post(body);
// check response
if (error == 0)
{
USB.print(F("3.1. HTTP POST OK. "));
USB.print(F("HTTP Time from OFF state (ms):"));
USB.print(F("\nServer answer:"));
USB.print(F(WIFI_PRO._buffer,WIFI_PRO.length)
}
}
void SendHttpData(){
//////////////////////////////////////////////////
// 1. Switch ON
//////////////////////////////////////////////////
error = WIFI_PRO.ON(socket);
if (error != 0)
{
USB.println(F("1. WiFi did not initialize correctly"));
ErrCount++;
}
else
{
// 2. Set url
error = WIFI_PRO.setURL( type, host, port, url );
if (error == 0)
{ USB.println(F("2. setURL OK"));
}
else
{
USB.println(F("2. Error calling 'setURL' function"));
WIFI_PRO.printErrorCode();
}
//Set content Type
error = WIFI_PRO.setContentType(ContentType);
// check response
if (error == 0)
{
USB.println(F("2. setContentType OK"));
}
else
{
USB.println(F("2. Error calling 'setContentType' function"));
WIFI_PRO.printErrorCode();
}
//////////////////////////////////////////////////
// 3. Join AP
//////////////////////////////////////////////////
// check connectivity
status = WIFI_PRO.isConnected();
// Check if module is connected
if (status == true)
{
USB.println(F("3. WiFi is connected OK"));
USB.println(body);
////////////////////////////////////////////////
// 3.1. http request
////////////////////////////////////////////////
error = WIFI_PRO.post(body);
// check response
if (error == 0)
{
USB.print(F("3.1. HTTP POST OK. "));
USB.print(F("HTTP Time from OFF state (ms):"));
USB.print(F("\nServer answer:"));
USB.print(F(WIFI_PRO._buffer,WIFI_PRO.length)
}
}
-
- Posts: 27967
- Joined: Mon Sep 28, 2009 1:06 pm
Re: Example of HTTP Post request for sending json data
Thanks for your contribution to the forum.
Who is online
Users browsing this forum: No registered users and 1 guest