Reputation: 41
I am writing a class in Qt that retrieves information from the Bricklink API (a LEGO database). It uses the QOAuth1 Class to authenticate and the QNetworkReply to capture the response from HTTP GET requests. This works fine, unless the data that is being retrieved is too big.
In the example below I request a specific inventory (list of LEGO pieces). When I request category_id 142, I get a nice list of 50 parts. But category_id 485 contains 75 elements and returns nothing. Not even an error.
void Category::getInventory()
{
QUrl url("https://api.bricklink.com/api/store/v1/inventories");
QVariantMap parameters;
parameters.insert("category_id", "485"); // 75 elements not OK
// parameters.insert("category_id", "142"); // 50 elements OK
QNetworkReply *reply = bricklink.get(url, parameters);
connect(reply, &QNetworkReply::finished, this, &Category::parseJson);
}
void Category::parseJson()
{
QJsonParseError parseError;
auto reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error()) {
qDebug() << reply->errorString();
return;
}
const auto data = reply->readAll();
const auto document = QJsonDocument::fromJson(data, &parseError);
if (parseError.error) {
qCritical() << "Category::getCategory. Error at:" << parseError.offset
<< parseError.errorString();
return;
} else {
QString strReply = static_cast<QString>(data);
qDebug() << strReply;
}
}
I am at a loss to find what is causing this. Is there a maximum limit on data that can be sent? Or some sort of time-out? Maybe bigger data needs to be captured in chunks?
Of course, there is the possibility that the API is not sending out the larger sets of data. As a test, I tried the same with a node.js solution and could see that the API does work with larger sets.
Any idea what I could do to find the cause of this issue?
Upvotes: 1
Views: 278
Reputation: 41
Sometimes you get lost staring in the wrong direction.
My code did work, but I depended on qDebug()
to show the results. I must stop doing that, because qDebug()
has a size limitation. As such it did not show the results.
I will never forget this... ;-)
Upvotes: 1