Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Regular Contributor
Posts: 61
Registered: ‎05-22-2011
My Device: Blackberry Torch
My Carrier: Airtel

Sending data over HTTP post in Cascades

Hi Everyone,


I am new to Cascades development. I am now learning how to code in Cascades for my next project. 

Can someone help me on how to send data (in bytes) over Http post in Cascades?


The requirement is like, I need to send data which is in JSON format to a web service. I saw few samples for accessing web content via GET method but I did not see a good example for POST method. 


Any help will be much appreciated. 


Thank you in advance. 

Posts: 689
Registered: ‎08-09-2010
My Device: Not Specified

Re: Sending data over HTTP post in Cascades



 Please check below thread 






feel free to press the like button on the right side to thank the user that helped you.

Posts: 38
Registered: ‎09-27-2012
My Device: 9930
My Carrier: airtel

Re: Sending data over HTTP post in Cascades

Hi all.,


I have this same doubt..,please help me..,the link provided here is useful but it does not fill my need. I need to send a json request like this with http post.

   "username" : "my_username",
   "password" : "my_password",
   "validation-factors" : {
      "validationFactors" : [
            "name" : "remote_address",
            "value" : ""

 Please help me..,I couldn't find a useful tutorial in this...


Thanks in advance.

Posts: 21
Registered: ‎09-18-2013
My Device: Z10
My Carrier: +

Re: Sending data over HTTP post in Cascades

Did you find the solution?

Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Sending data over HTTP post in Cascades

[ Edited ]

Here is GET/POST example also



@varghesekiran @ZuzooVn

I know of two options for creating JSON



Use QVariant/QVariantMap/QVariantList

QVariantMap map; // username nad password
map.insert("username", "my_username");
map.insert("password", "my_password");

QVariantMap map2; // name and value
map2.insert("name", "remote_address");
map2.insert("value", "");

QVariantList list; // [name and value]
list << map2; // append name and value

QVariantMap map3; // validationFactors
map3.insert("validationFactors", list);

map.insert("validation-factors", map3);

And now you need to serialize result (map) You can use external JSON library like a QtJson http://qjson.sourceforge.net or build in like JsonDataAccess

JsonDataAccess json;
QByteArray array;
json.saveToBuffer(map, &array); /* AND THE RESULT IS { "password" : "my_password", "username" : "my_username", "validation-factors" : { "validationFactors" : [ { "name" : "remote_address", "value" : "" } ] } } */


Or you can build it directly with QByteArray

QByteArray json;

json += "{"; // start brace
json += "\"username\": \"my_username\","; // username
json += "\"password\": \"my_password\","; // password
json += "\"validation-factors\": {";
json += "\"validationFactors\": [";
json += "{ \"name\": \"remote_address\",";
json += "\"value\": \"\" } ] }";
json += "}"; // end brace

   "password" : "my_password",
   "username" : "my_username",
   "validation-factors" : {
      "validationFactors" : [
            "name" : "remote_address",
            "value" : ""

Hope it helps 

If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog