Welcome!

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

Reply
Contributor
puguasoft
Posts: 42
Registered: ‎02-10-2010
My Device: Nexus One (Android)
My Carrier: AT&T
Accepted Solution

Programmatically Posting/Getting HTTP Network Request

Hi,

 

I have read the Networking documents here as well as tried out the httptest sample app.

 

Everything seems to work fine when the network request is invoked by the UI, manually.  e.g. The user presses the "Post!" button in the Post Requests screen within the Http Test sample app and the PostHttp class goes on and makes the Post request and returns the body of the response successfully.

 

However, what I'm trying to do is invoke the same Post request programatically, e.g. when the app first starts or maybe in a timed/delayed thread.  What I did to test this is out is added the following code in the HttpSampleApp.cpp class at the end of constructor:

 

HttpSampleApp::HttpSampleApp()
{
    ...
    ...

    std::cout << ">>>>> POSTING...." << std::endl;
    PostHttp post;
    post.post("");

}

 

I added some debug messages in the PostHttp.post() and PostHttp.onGetReply().  When I start the app, I can see that the HttpSampleApp() constructor calls the PostHttp.post() method just fine, however the onGetReply() never gets called!  It seems like the HTTP POST network request is just waiting out somehwere and never completes/finishes.  I do not see any errors or timeouts occuring - basically, nothing happens after PostHttp.post() is called.

 

Can anyone please shed any light as to how to PROGRAMATICALLY make Http POST and GET requests?  Again, the code works perfectly fine when invoked by manually, via the QML UI (just like in the sample code).

 

Thanks for any help!

~Chris
PuguaSoft LLC
Please use plain text.
Contributor
puguasoft
Posts: 42
Registered: ‎02-10-2010
My Device: Nexus One (Android)
My Carrier: AT&T

Re: Programmatically Posting/Getting HTTP Network Request

The solution was to initialize reference the PostHttp as a pointer.

 

e.g.

PostHttp *post = new PostHttp();
post->post("");

 

~Chris
PuguaSoft LLC
Please use plain text.