ErrorString QNetworkReply "premature end of the document.

Everyone knows about this problem?  The answer comes back correctly for smaller responses (i.e. https://developer.blackberry.com/cascades/files/documentation/images/model.xml), but for larger responses, the response contains data answer, but not all (and I get the errorString "Premature end of the document").  Here is an example URL for a greater response: https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen _...

The errorString seems to come from the QXmlStreamReader, but the fact remains that the QNetworkReply has an incomplete answer.

I followed the tutorial of Communication HTTP almost exactly.  Here's a relevant code:

main.cpp:

void ApplicationUI::initiateRequest(QString username, QString password) {
    // Start the activity indicator
    mActivityIndicator->start();

    // Create and send the network request
    QNetworkRequest request = QNetworkRequest();
    QUrl url("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_...");
    request.setUrl(url);
    mNetworkAccessManager->get(request);

}
void ApplicationUI::requestFinished(QNetworkReply* reply) {

    // Check the network reply for errors
    if (reply->error() == QNetworkReply::NoError) {

        qDebug() << "\n reply is: " << reply->readAll();

                QXmlStreamReader xml;

                QMLByteArray data = reply->readAll();                xml.addData(data);

                while(!xml.atEnd() && !xml.hasError()) {                      // parse here                }

        /* Error handling. */
        if (xml.hasError()) {
            qDebug() << "\n errorString is: " << xml.errorString();
        }

        xml.clear();

        mActivityIndicator->stop();

    } else {
        qDebug() << "\n Problem with the network";
        qDebug() << "\n" << reply->errorString();
    }

}

applicationui. HPP:

// Default empty project template
#ifndef ApplicationUI_HPP_
#define ApplicationUI_HPP_

#include 

using namespace bb::cascades;

namespace bb { namespace cascades { class Application; }}

/*!
 * @brief Application pane object
 *
 *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class ApplicationUI : public QObject
{
    Q_OBJECT
public:
    ApplicationUI(bb::cascades::Application *app);

    Q_INVOKABLE void login(QString username, QString password);

    /*!
     * Initiates the network request.
     */
    Q_INVOKABLE void initiateRequest(QString username, QString password);

    virtual ~ApplicationUI() {}

private slots:
    /*!
     * Handles the network reply.
     */
    void requestFinished(QNetworkReply* reply);

private:
    ActivityIndicator *mActivityIndicator;
    QNetworkAccessManager *mNetworkAccessManager;
};

#endif /* ApplicationUI_HPP_ */

applicationui.cpp

// Default empty project template
#include "applicationui.hpp"

#include 
#include 
#include 

#include 

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app", this);

    AbstractPane *root = qml->createRootObject();

    mActivityIndicator = root->findChild("indicator");

    // Create a network access manager and connect a custom slot to its
    // finished signal
    mNetworkAccessManager = new QNetworkAccessManager(this);

    bool result = connect(mNetworkAccessManager,
            SIGNAL(finished(QNetworkReply*)),
            this, SLOT(requestFinished(QNetworkReply*)));

    Q_ASSERT(result);
    Q_UNUSED(result);

    app->setScene(root);
}

I'd appreciate any help!

My apologies, looks like I posted a little prematurely on this one.  The answer came back in its entirety.  There were a couple of diversion that distracts me major problems:

  1. I was the XML parsing incorrectly
  2. It seems that if the answer is too long in the unit log, then the log of the unit will cut the message.  Is it possible to configure the log device is not for this?
  3. It seems that the response message has disappeared after using the following statement by qDebug().  This removes the data of 'response '?  I am a newbie in C++ from Java...
    qDebug() << "\n reply is: " << reply->readAll();
    

Tags: BlackBerry Developers

Similar Questions

  • HTML export: why are my images at the end of the document?

    I hope it's a very simple question, even embarrassing. I'm in position regrettable to have to get an InDesign converted HTML document can be used for a project, despite having never used InDesign before, so I start to almost zero knowledge here.

    The export process seems simple enough, except that the images that appear inline (integrated with the text, you'd see in most publications) are simply thrown at the end of the document when I export to HTML. Everything in the HTML code looks very good, and if I export to PDF, even images appear as expected. Same problem if I export to epub, so it seems to be something specific to the HTML-based export formats.

    I've read enough documentation to get the impression that this is not normal, but I don't know where to begin to understand what is happening and how to fix it. Any advice would be greatly appreciated.

    These images are probably not inserted graphics and are probably independent of graphics. Confirm it by: movement text block, actually moving graphic with framework?, or select text, and then switch to editor mode, you see an anchor icon in the text? If you find that the graphics are not online, you will need to place them in the thread of the text.

  • Duplicate the spread not at the end of the document

    When you duplicate a spread, how can it be reproduced on the next page rather than at the end of the document?

    Thanks Ian

    not sure, but you can drag 'alt' propagation from a specific point and inserts a copy it if that helps.

    see you soon

  • CS4 has "Back" and "at the end of the document.

    Scene1

    I'm in TextEdit , whipping through a FIND, speeding as usual and all of a sudden "Whoa" I missed that one. No problem. Just press previous. This is a very useful option.

    Q1: Is there a similar option hidden somewhere in CS4?

    Scene 2

    I am looking through a CS4 document to help find and wanted to jump out of the for making any changes. I finish the Assembly, and then I want to keep FIND it right there where I was stopped at the end of the document. CS4 does not offer this option. It goes to the end and then looping back to the beginning and takes me through the lot. IE if you are almost at the end of the document and do not look at where you are, you can eventually find the document twice.

    Q2: Can I configure FIND to boot from the insertion point and complete his research at the end of the document?

    A1. Alas, no.

    A2. Alas, no.

    I also miss the two of them on an almost daily basis.

    Submit them to InDesign Feature Request; Maybe someone up there is listening.

  • end of the document carriage return

    Hi, I'm new in Indesign Scripting,

    How to read and understand if there is a '\r' at the end of my document?

    Thank you

    You can set the story with a variable, for example. selecting a block of text of this story:

    var myStory = app.selection[0].parentStory;
    

    Now you have access to for example all InsertionPoints and all the characters in this story.

    You could ask the last character and its content (the chain not formatted this character):

    if(myStory.characters[-1].contents == "\r"){
        myStory.characters[-1].remove();
        }
    

    Or, if you want to add a character (a paragraph return) at the end of a story, you can see:

    if(myStory.characters[-1].contents !== "\r"){
        myStory.insertionPoints[-1].contents = "\r";
        }
    

    Be careful when you add special characters.

    See the list here:

    Adobe InDesign CS6 (8,0) object model JS: SpecialCharacters

    Assignment of a special character is like the assignment of a string for the content:

    myStory.insertionPoints[-1].contents = SpecialCharacters.COPYRIGHT_SYMBOL;
    

    Hope that helps!

    Uwe

  • Page added at the end of the document when overtext in textframe

    Hello

    I am very new to indesign, so I don't have knowledge of expert level in Indesign.

    Currently, I am facing problem with overtext textframe. When I'm trying to place the image inside the textframe who has the ignoreTextWrap property has the value

    for real it will create the next textframe linking on the last page of the document.

    Any help?

    Hello

    Smart text reflow options do these actions.  Preferences settings go--> Type--> uncheck the Smart Text reflow.

  • ActiveX slider at the end of the word document

    Hi all
    I work with LabView 2014 and MS Word 2007

    Using ActiveX I managed to copy a Word document template required sections (tables/images NOT text) to the Clipboard. I checked this manually by pasting the Clipboard into a new word document.

    However, I need programmatically paste the contents of the Clipboard at the end of a word document, but cannot find a way to set the cursor position to the end of the word document ready to paste using activex. Does anyone know how to set the position of the MSWord cursor at the end of the document using ActiveX?

    Thanks in advance.

    Thank you very much James this solution works but.

  • Links to the site saved in the Document Word on themselves wrote on my test

    I wrote an essay on the universe of Marvel Comics and at the end of the document, I put some links of website for the bibliography, II registered and send it by e-mail to my teacher. After that I sent, I noticed in the attachments that my Word Documents was Dox instead of Doc, it was strange that I open it and the entire contents of my test has disappeared and replaced by the text of the links I had saved. What I do / how do I get it back?

    You must have accidentally clicked on the 'paste' button and pasted into the content.  There is no way to do it on his own.

    But this is not the issue now.  To recover, you have some options that may be available, depending on your settings.

    First of all, learn how to restore previous versions of a file.  This the demo video here explains how (they explain it in terms of restoring a deleted file, but it works the same restore to an earlier version of a file that has been changed just simply, not deleted).

  • Box of signatures on the document but the signing of the document is outside of the standard box

    Hello

    I produce the document for signature - see image attached please.

    While the model for the customer to sign is there, at the bottom right in a box, when I try to sign as a client, my signature is going off the beaten path where it should be. Can you please help because it's urgent?

    Echosign problem.png

    Hi antigoni,.

    Please make sure that you have placed the Signature fields on the document, another sign of Adobe will add a Signature block at the end of the document and the same thing is happening in your case.

    On the send page click on the box "Preview & Add Signature Fields" and then hit, not place the Signature fields for the signatories to the document.

    Kind regards

    Nicos

  • Read reads aloud just one page and stops; 'Read the document' does not work

    My Adobe Reader X software! worked very well in the function "Read Out Loud". I just downloaded Acrobat Reader DC and am disappointed by the Read Out Loud feature. It will read a single page and then stop; The "read at the end of the document" will not work. The player will stop after reading a page. Help!

    Hi Evona,

    I recommend to Open (ctrl + k) Reader preferences and uncheck 'Enable protected at Startup Mode' in the category '(enhanced) Protection' and restart the CD player. Let me know how it goes.

    Kind regards
    Rahul

  • I want to add a document to the end of another document in pages. I've seen a solution here by copy

    I can't add to the documents together in pages. I want to add a list of references on the end of an assignment, but they are on 2 separate documents, thank you.

    Open the first document Pages. Add a new section. Copy / paste your list of second document reference material in the first page of the News Section. Record.

  • How does the index start and end in the reference Word text VI to a word document?

    How a correlation between the index values start and end to a position or coordinate in a Word document?

    Is it a type of lookup table that will refer to a value of say '35' (to start) to a line or a particular character of the position in a Word document? There is nothing in LV help which explains nothing other than the value '-1 '.

    Hey, JayB,.

    The start and end of the Text.vi in Format Word values are the positions of the characters in the document. The values start at 0 on the first (or ASCII character such as a space, tab, or carriage return) and for each character (or the ASCII character). So for example if I wanted to "BOLD" the word "carrots" in the list below, where the values start at 0 on the word 'grocery store '.

    Grocery store:

    Apples

    Black berries

    Carrots

    Detergent

    Then I would enter a start 33 and the end of the 40s, making sure to count the ramasseherbe returns and spaces.

    I hope this helps.

    Logan H

  • I try to get my printer to print a document, it goes through the indices of normal routine but in the end, it shows the number of the DOCUMENT to print.

    Whenever I try to access my printer to print a document, it goes through the indices of normal routine but in the end, it shows the number of the DOCUMENT to print.

    Original title: printer

    What kind of printer do you use? You use the latest drivers on the manufacturers website? Where are you seeing the printing error DOCUMENT No.?

  • Insert all pages at the end of a document

    I'm trying to do something that * should * be easy: Add all the pages document A the end of B. There is even a predefined command to copy pages from one document to another: Doc.insertPages. My problem lies within the limits of this method.

    See, whenever the script is run, I don't know how many pages is an advance in the document. Doc.insertPages allows me to specify the first and last page I want to copy, but he only expects a number. Also, unfortunately, using-1 to specify the last one does not work for the page index numbers how it works for the array index number. So, here is what I have so far:

    printDoc.insertPages({
        nPage: printDoc.numPages - 1,
        cPath: labelFile,
        nStart: 0,
        nEnd: -1
    });
    

    Here, printDoc is my document B, and labelFile is my document to. I can easily say the method to insert the pages after the last existing page in document B by calling its NBPAGES property and subtracting 1. After all, the document is already opened and Acrobat can count the pages inside. Has not the same for the document; the Doc.insertPages does not document A method - she wants only a path String to it. So I can't say beforehand how many pages in it.

    I guess I * could * have just the script open document has temporarily, just long enough to store the number of pages in a variable, which is then used in the Doc.insertPages method, but I was expecting something a little cleaner than that. Thoughts/ideas?

    As indicated in the documentation: "If a page range is not specified, the method gets all the pages from the source document."

    So just do not specify start and nEnd. More information: https://acrobatusers.com/tutorials/inserting-pages-pdf-acrobat-javascript1

  • How to add a column at the end of the table of the already designed the document... ?

    Hello

    I am writing a javascript to add a column at the end of the table in the Indesign document. using our plug-in, we have created the Indesign document.

    Each table I want to add an extra column at the end. Is it possible... ? Please help me if anyone has the idea in this regard.

    Thank you

    Vimala L

    Hi Vimala,

    Please try the JS code below, copy the following code will add the new column in each table last column after.

    var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    
    for(i=0; i
    

    THX,

    csm_phil

Maybe you are looking for