JSON RPC how to the POST of blackberry?

Hello

I work on JSON and trying to call a JSON-RPC URL and DISPLAY data.

However, I realized that my code is actully false. I messed up the settings and property names.

Can we say the method appropriate to the POST of blackberry?

Here is the part of the work of my request code code...

Public Sub postViaHttpConnection (String url) throws IOException, JSONException
{
C HttpConnection = null;
OutputStream os = null;
InputStream is = null;
String s ="";
        
c = (HttpConnection) Connector.open (url);

c.setRequestMethod ("POST");
c.setRequestProperty ("Content-Type", "application/json");
                  
OS = c.openDataOutputStream ();
       
"{" s = '{\"id\': 1, \"method\ ': \"login\ ', \"params\ ': {\"user\" ": \"John\ "", \"password\" ": \"John123\ "}}"
        
OS. Write (s.GetBytes ());
OS. Flush();
OS. Close();
        
        
is = c.openInputStream ();
        
int len = (int) c.getLength ();
        
If (len > 0)
{
real int = 0;
int BytesRead = 0;
data Byte [] = new ubyte [len];
While ((bytesread! = len) & (real! = - 1))
{
real = is.read (data, bytesread, len - bytesread);
bytesRead += real;
}
            
Get the JSON string
s = new String (data);
}
        
is. Close();
}

Tags: BlackBerry Developers

Similar Questions

  • How downgrade the operating system BlackBerry 10.3.3 z10?

    I recently got updated to beta 10.3.3 my z10 with automatic charger BlackBerry, I jot m satisfied with this is there is no music, Manager of gallery files all, how downgrade to 10.3.2? or must I wait for the alpha upgrade?

    Sorry, as you have been informed with the 10.3.3 upgrade developer OS, it is not possible to downgrade. You have an OS developer for the test, with some modules disabled.

    You will have to wait for the full upgrade.

  • How to add a custom menu in the menu system, as the list of Blackberry contacts

    I would like to add a custom menu tinto menu system, such as the list of Blackberry contacts, when users enter in contact list and select the custom menu, it will open my client and send a few s parametertin my application as the contact name, telephone number, please tell me how and what version of the OS can do this.

    It's still not clear to me what you want to achieve.

    You can use http://www.blackberry.com/developers/docs/6.0.0api/net/rim/blackberry/api/menuitem/ApplicationMenuIt... to add a menu item to some system applications, for example the address book. you get a context object, in a BlackberryContact, you can process or use the address book.

    Your second post seems to allude to http://www.blackberry.com/developers/docs/6.0.0api/net/rim/blackberry/api/messagelist/ApplicationInd... , it is used to place small flags with or without the number, such as that used for unread e-mail messages.

  • How can I post pictures to the resulting internet forum photo album?

    How can I post pictures to a photo album on an internet forum?

    Use Safari or any web browser that supports the media browser and upload them (in the window download selection to the bottom of the left pane under media source == > photos == > Photos)

    LN

  • accidentally credited the poster of evil with a solution, how can I change?

    So, this is my third post to this community. My first post asked for a solution to a problem I had. My second post was to thank the poster who provided the solution, and then click the correct answer in the box of the poster. At least that is what I thought I did. However my second post has now determined in the thread that the post correct answer. Shortly after, I received a private message the poster who correctly answered to my question, angry with me to credit me instead of the correct poster for having responded to the question. How can I fix this error? I have checked and don't see any obvious way to cancel my previous answer mouse click.

    You can not fix it. Once the post is marked solved and points to be awarded, it cannot be changed. It was a good faith mistake. Don't worry about this.

  • How get the formatting in the posts here? Attn: moderators...

    Sorry to ask, but: how to get formatting in posts here? It originally had, and then he disappeared may 2 months ago. These days, even if I type in a paragraph in the middle of a station break, the post is ultimately appears as 1 long, run on the provision. I suspect that it is unique on a per account basis, as I see some messages (but not all) with paragraph breaks, but I just can't make it work. Same passage in my account settings (Advanced Options, content editor) of the 'Enhanced' in "Plain text" or back again once, does nothing. Similarly, links appear just as text and not as links today for me, when I insert the. Help? (And there's a paragraph without appearing break just before the word "Help" here...).

    In IE11 add dell.com to compatibility view setting...

  • How do I open the browser web blackberry with a url given by a click of a button.

    Hi all

    I'm developing an application in which I want to open the browser web blackberry with a URL given using a click of a button. How can I do that. I use this code inside the earpiece button

    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
    Private private = Browser.getDefaultSession ();
    browserSession.displayPage ("http://www.google.com");
    }

    What is a good way to do this? Please help me...

    Yes

  • How to free the memory through BlackBerry Webworks Code

    I am faced with the question as "the available memory on your device is low. Close to some of the items below. "When I close the application of phonegap webworks after a few shots. How to free the memory through BlackBerry Webworks Code.

    It is a good number that in the face of demand for the BB webworks. Very common when you dynamically load images or by using the browser in your application. Please visit this link for details...

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/device-memory-is-low-issue-for-a...

  • How can I use ApplicationMessage to pass my application's message in the Inbox of BlackBerry?

    Hi everybpdy,

    I was told that it is possible to use the ApplicationMessage class to transfer my application's message directly to the Inbox of BlackBerry, but I've yet to find a relevant example of this use. Does anyone have an idea on how I could do this?

    Thanks in advance.

    Take a look at the messagelistdemo that is included with the JDE BlackBerry and BlackBerry Java SDK.  It shows how to do exactly that.

  • How to view the symbols of the apostrophe (') on the map of blackberry

    Hello world

    I display several point on the map of Blackberry pin code and adding the label and description of the stem stitch,.

    in that sentence I put symbols of the apostrophe (') (ex-aujourd'hui), after that the card does not appear.

    Please help me how display only.

    Thank you.

    You will need to use entities.

    var = ', description = "Today\" zoom is... ". "means that var contains:

    ... description = zoom 'today ' =...

    This naturally leads to malformed XML.

    Do this instead:

    var = "... description = zoom 'Today' is...". »

  • How to change the icon of the Application on Blackberry JDE 6

    Hi, do someone know how to change the icon of the application of the project, we have created in the JDE? I searched the forum, and suggestions should go to the project properties, go to the "resources" tab and add the icon file. I have also included the file icon (PNG 68x68pixel) to the project.
    But this does not seem to work for me.
    I also tried to build clean, remove files jad and others, always not when I tried the app Simulator or on real device. Any help will be appreciated.
    I use Blackberry JDE 6, test the application on the actual device (9800), Simulator (9700). And the app that I'm testing is just a pushscreen simple helloWorld app, not a lot of code here. Thank you.

    Here's how to put the icon in BlackBerry JDE.

    1. Add the image to your project.
    2. Right-click on the image and choose Properties.
    3. Check "use as icon for the Application.
    4. Rebuild the application.
  • How to get the Version of Blackberry Messenger in webworks

    I would like to know if its possible for me to get the version of Blackberry Messenger installed on Blackbery device from my application webworks.

    I need to know how to do that because I intend to connect my blackberry webworks for BBM 6 application. So I need to know if the user has version 6, so I can tell them to upgrade if it is not.

    Thank you


  • How can read/write on a file and stored in the internal memory of the device, 10 BlackBerry?

    I want to store a string value of my request. After that, I remove my device app & reinstall my app. I want to get the previous value stored in recently installed application.

    I think that if I can write the value to a file that is located in the internal memory of the device. After that, I read the value of this file in any time. I am new to the cascade of Blackberry, so I don't know how to write / read a file.

    Please help me...

    Thanks in advance.

    Hi all

    I solved my problem. I'm using the code below:

    QString call: readFromFile()
    {
    QFile textfile("shared/documents/Test.txt");
    QString str ="";
    If (textfile.open(QIODevice::ReadOnly |) QIODevice::Text))
    {
    QTextStream in(&textfile);

    Str = in.readAll ();
    }
    else {}
    QTextStream out (stdout);
    off<>
    }

    TextFile.Close ();

    return str;
    }

    Thank you all for the valuable suggestion...

  • How to use the post method?

    Hello

    I need to send an image on the server using the post method.

    I connect using Http, like this:

    HttpConnection _http = (HttpConnection) Connector.open (address);

    can someone provide an example of how can I use a post method to send the data to the server?

    Kind regards

    I solved the problem. Here is my code, which works:

    Bitmap _bitmap = new Bitmap(Display.getWidth(), Display.getHeight());
                Display.screenshot(_bitmap);
    
    JPEGEncodedImage _jpg = JPEGEncodedImage.encode(_bitmap, 20);
    DataBuffer _db = new DataBuffer();
    _db.write(_jpg.getData());
    
    _http = (HttpConnection)                    Connector.open(_url, Connector.READ_WRITE);
    
    _http.setRequestMethod("POST");
    
    _http.openOutputStream().write(_db.toArray());
    _http.getResponseCode();
    

    Kind regards

  • How to debug the java application BlackBerry on Eclipse with a BlackBerry Smartphone?

    Problem:

    How to debug the java application BlackBerry on Eclipse with a BlackBerry Smartphone?

    The following procedure:

    http://docs.BlackBerry.com/en/developers/deliverables/12002/Debug_an_app_on_BB_device_656366_11.jsp

    Error:

    An internal error occurred during: "launch WMMS_ACC_video_test0".
    java.lang.NullPointerException

    I found that other methods of debugging.

    If anyone knows how to do it please tell me.

    Thank you for your attention.

    http://www.BlackBerryForums.com/developer-forum/107455-debugging-live-device.html

    Solution:

    Start the IDE
    Connect your device to the PC via USB
    compile your application and load on the device
    in JDE - Debug - attach to-Pocket
    ignore all dialog boxes
    do the breakpoint
    Start your application on the device

Maybe you are looking for