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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Developer
Posts: 27
Registered: ‎11-13-2013
My Device: Q10
My Carrier: Verizon
Accepted Solution

Help with HTTP Post JSON Request

Still fairly new to QT so I'm trying to send a http post request with some json, I'm pulling the json from a file and that seems to be working fine but I keep getting a http 500 error. I just want to ensure my code is correct before contacting the company who webservice I'm using here is my code:



 JsonDataAccess jda;
    QVariant list = jda.load(QDir::currentPath() +"/app/native/assets/jsonData/myjson.json");


    QUrl webServiceUrl("https://thewebserviceurl/");
    QNetworkAccessManager* networkAccessManager = new QNetworkAccessManager(this);
    QNetworkRequest request (webServiceUrl);

    request.setRawHeader("Content-Type", "application/json");
    request.setRawHeader("Content-Length", QByteArray::number(list.toByteArray().size()));

    QNetworkReply *reply = networkAccessManager->post(request, list.toByteArray());


I have a feeling I'm passing in the json data into the post method incorrect. Any assistance is appreicated

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

Re: Help with HTTP Post JSON Request

[ Edited ]


You are sending an empty string to server because list.toByteArray() returning empty string.


You need save list to QByteArray;


QByteArray result;
jda.saveToBuffer(list, &result);

// and then

QNetworkReply *reply = networkAccessManager->post(request, result);



Just load the json file with QFile

QFile file(YOUR_JSON);
if (!file.open(QIODevice::ReadOnly)){
    qDebug() << Q_FUNC_INFO << file.errorString();
QByteArray result = file.readAll();

QNetworkReply *reply = networkAccessManager->post(request, result);

 Hoe it helps Smiley Wink


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
New Developer
Posts: 27
Registered: ‎11-13-2013
My Device: Q10
My Carrier: Verizon

Re: Help with HTTP Post JSON Request

That did the trick thanks!