data post to httpconnection http 302

I am tryind to send settings via the post for an httpconnection, but always get http 302 response code

This is my code:

HttpConnection conn = conn =  (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
URLEncodedPostData encoder = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
encoder.append("param1","value");
encoder.append(...);
conn.setRequestMethod( javax.microedition.io.HttpConnection.POST );
conn.setRequestProperty("Content-Length", String.valueOf(encoder.getBytes().length));
conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
OutputStream oStream;
oStream = conn.openOutputStream();
oStream.write( encoder.getBytes() );
oStream.flush();

What is courious, is that if I use a BrowserField2 I can connect without a problem by using this code:

BrowserField browserField = new BrowserField();
final MainScreen screen = new MainScreen();
screen.add(browserField);
String postData = "param1=value&aparam2=" ...;
Hashtable header = new Hashtable();
header.put("Content-Length", "" + postData.length());
header.put("Content-Type", "application/x-www-form-urlencoded");
String url = "http://...";
browserField.requestContent(url, postData.getBytes(), header);
UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
        UiApplication app = UiApplication.getUiApplication();
        app.pushScreen(screen);
    }
});

The problem is that I net get params return and I don't know how to get them using browserField

302 means content moved, you probably start again in the new url request (it removes the header).
the browserfield probably follows the redirection by itself.

Tags: BlackBerry Developers

Similar Questions

  • stuck with an http 302 response

    Hi all

    I am developing an audio streaming software. It works first is authenticating with the API audio site authentication. Then, after the session information, I can ask for each individual audio files. Now, the trick is that the url to each of the audio file should be only requested/available only once, after the first access, the ticket is expired immediatelyand then one can only access other files in the same session.

    What I'm trying to do here is to first download and buffer each audio file, given the valid URL. I use connection tcp here because audio files can be very large (3-5 MB). (including ";) (deviceside = true"in the url) the problem is when I change the connection of State ready to open the State by opening the input stream or to receive the response code. The piece of code I used is:

    String location = url+";deviceside=true";HttpConnection s = (HttpConnection) Connector.open(location);System.out.println("Response Code: "+s.getResponseCode());System.out.println("Response Message: "+s.getResponseMessage());                long length = s.getLength(); InputStream in = s.openInputStream(); //open stream
    
    byte[] data = new byte[256];DataBuffer db = new DataBuffer();int chunk = 0;while (-1 != (chunk = in.read(data))) {    db.write(data, 0, chunk);}in.close();s.close();data = db.getArray();// data is always empty for some reason
    

    The response code I get is always 302 "Found", but when I open the input stream, the stream is empty. I tried to copy the individual url for each audio file and then paste into my firefox, files can be downloaded without problem. The audio file would also run the end of the file > openURL in Windows Media Player. The url of the individual audio file is in the format ""http://play.audiowebsite.com/user/df98sdfdf98sdfdf98sdfdf98sdf1234.mp3 ". " One thing I've observed is that when I try to open the url in firefox, he asks me if I want to download from http://s14.audiowebsite.com/, which means that there redirect me to one of its servers for me.

    How can I download these files from my BlackBerry application. I tried to solve this problem for the last 5 days and have made very little progress. I searched every corner of this forum. This is my last resort. All AIDS are appreciated.

    I use JDE4.7 and Simulator 8820

    I remember most of the tools really good media works only with linux (these are widely considered

    as hacking tools). However, this problem is probably right http.

    If you're stuck on windoze, get cygwin and things like wget allows you to test your server.

    Or, go to ietf.org and know what a 302 response is supposed to mean.  Note it gets complicated

    When some sites wireless do smart things like meet the cookies too etc.

    In this case,.

    $ wget - O ~/xxx s - v "http://play.audiosite.com/user/df98sdfdf98sdfdf98sdfdf98 ".
    sdf1234.MP3 ".
    -06: 58:00 - http://play.audiosite.com/user/df98sdfdf98sdfdf98sdfdf98sdf1234.mp
    3
    => ' / xxx'
    Resolving play.audiosite.com... 63.119.44.197
    Connecting to play.audiosite.com [63.119.44.197]: 80... connected.
    Query HTTP sent, awaiting response...
    1 HTTP/1.1 302 found
    2 date: Wednesday, February 18, 2009 11:51:07 GMT
    3 Server: Apache/2.2.3 (CentOS)
    4 set-Cookie: COOKIE = 10.5.16.253.1234957867765295; Path = /.
    5 rental: http://play.audiosite.com/
    6 content-Length: 64
    7 vary: accept-encoding of the User Agent.
    8 cartoons: aalander3
    9 connection: close
    10 content-Type: text/html; Charset = UTF-8
    Location: http://play.audiosite.com/ [more]
    -06: 58:01 - http://play.audiosite.com/
    => "/ r/xxx".
    Connecting to play.audiosite.com [63.119.44.197]: 80... connected.
    Query HTTP sent, awaiting response...
    1 HTTP/1.1 200 OK
    2 date: Wednesday, February 18, 2009 11:50:52 GMT
    3 Server: Apache/2.2.3 (CentOS)
    4 vary: accept-encoding of the User Agent.
    5 cartoon: aalander5
    6 connection: close
    7 content-Type: text/html; Charset = UTF-8

    [ <=>                                 ] 27,674        --.--K/s

    06:58:01 (263.92 MB/s) - ' / ho / xxx ' saved [27674]

    $

  • java.io.IOException: null for setRequestMethod ("POST") of HttpConnection

    Hello

    I m opening HttpConnection with

    HttpConnection connection = null;
    
    try
    {
        connection = (HttpConnection)Connector.open(targetURL);
        int status = connection.getResponseCode();
        System.out.println("status is : " + status);
    
        if (status == HttpConnection.HTTP_OK)
        {
           System.out.println("HttpConnection.HTTP_OK : "+connection.getResponseMessage());
           connection.setRequestMethod("POST");
           //connection.setRequestMethod(HttpConnection.POST);
           System.out.println("connection.setRequestMethod(POST);
           /*connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
           connection.setRequestProperty("Content-Language", "en-US");
    
           //Send request
           wr = new DataOutputStream(connection.openOutputStream());
                         wr.writeChars(sendRequest);
                         wr.flush();
                         wr.close
           }
    }
    catch (IOException e)
    {
        System.err.println("ERROR =====> " + e.toString()+":: "+e.getMessage());
        e.printStackTrace();
    }
    

    But I m is

    java.io.IOException: null for setRequestMethod("POST")
    

    Until it runs fine.

    What is the problem in my code?

    You do it in the wrong order. You need to do the setRequestMethod(), the setRequestProperty() and the openOutputStream() before calling getResponseCode().

  • How to import xml data from a site http with PL/SQL

    Hello

    I created a table with an XML field as follows:

    1 save the scheme "service."

    2. create table 'command.

    3 imported data in the table 'Command' of string data.

    Everything works perfectly fine, but I need insert the data directly from a URL like this

    http://API.mercadopublico.CL/Servicios/v1/Publico/ordenesdecompra.XML?Fecha=02022014 & ticket = F8537A18-6766-4def-9E59-426B4FEE2844

    attached I include codes

    Please can you help me with the solution.


    Thank you very much

    Hi Carlos,

    You can use HTTPURITYPE to access the resource by its url:

    insert into Ordenes values (
      1
    , httpuritype('http://api.mercadopublico.cl/servicios/v1/publico/ordenesdecompra.xml?fecha=02022014&ticket=F8537A18-6766-4DEF-9E59-426B4FEE2844').getxml()
    );
    

    If you're on 11g, you may also need to set an ACL for the request.

  • Firefox is not redirect when it gets an HTTP 302

    After completing a simple form on this page:
    https://bitdango.com/register/email

    The page should redirect to this page:
    https://bitdango.com/register/verify

    Instead, nothing happens. The browser is not simply redirect.

    I tried a relative and full URLS in the 'Place' of the redirection property, nor work.

    Why not the browser redirect? Users begin to use Chrome instead of Firefox because of this.

    I'm glad you solved the problem. Information on SPDY to https://en.wikipedia.org/wiki/SPDY .

    To avoid other people have this problem, I suggest that report you it as a bug through https://bugzilla.mozilla.org/.

  • Post cloning question: https does not

    Hi all

    I got (I hope) clone of the db layer and the layer of apps using clone fast.

    It's system rac db level at 2 knots, and so the application layer is a 2 nodes.

    When trying to load the https url, it does not load and displays "Internet Explorer cannot display the webpage"

    versions:

    EBS: 12.1.3 and db 11.2.0.2.

    Under files, settings:

    s_webentryprotocol is https

    s_login_page = https://ebsuat.domanin/OA_HTML/Appslogin

    s_enablesslterminator = no entrance!

    and s_active_webport = 443

    I believe that requires the above is all that's fixed at... What am I doing wrong here?

    Please see the following documents.

    The use of Oracle 11 g Release 2 Real Application Clusters with Oracle E-Business Suite Release 12 [823587.1 ID]

    Cloning of Oracle E-Business Suite Release 12 RAC systems compatible with the Rapid Clone [ID 559518.1]

    An "Internet Explorer cannot display the webpage" error, please check that apache save files as well as the details in the application.log file.

    Please also confirm that AutoConfig completed successfully on all nodes of the layer.

    Thank you

    Hussein

  • Re-create the delayed data post-upgrade migration work?

    Hi all

    After setting up our new 12 c SGO (approach-system-2, which is both an old and new are running at the moment), I spent a number of test for the new OMS12 machines and performed the work of migration of data charges and deferred taxes.
    Delayed data migration job "metrics" has failed, and - unfortunately not check documentation first - I killed the work failed because I hoped that this would enable me to restart.

    Oracle documentation:
    "To revive a failed job, click the status icon to the work page. On the page of work performed, click on change. On the Edit < JobName > work page, click on submit to rerun the task. »

    Now I can revive neither labour nor the system seems to be able to recreate - y at - it a possiblity of getting this job back in there? Or maybe run it at least manually? Historical metrics data collected has been one of the reasons that we have decided to approach system-2 in the first place, and go through the process of establishing WHO 12 once seems excessive to us.

    Every help is very appreciated!

    Published by: user13085691 on February 13, 2012 02:50

    Of performance (or re-track/restart) the DDMP process manually in a 2 EM GC 12 c upgrade/migration system. Use the following anonymous PL/SQL:

    Start
    em_metric_data__upgtmprl.migrate_all_partitions;
    end;
    /

    In one EM GC 12 c upgrade/migration system, use:

    Start
    em_metric_data__upgtmprl.migrate_all_partitions (true);
    end;
    /

    You only be able to run a single instance of this at the time, so if you try to run it and the background thread is actually still there, it will be ineffective and go back to the SQL prompt.

    To see a timeline of all errors during DDMP or Active Directory Management PACK, run the SQL code following in the 12 c EM GC as SYSMAN repository:

    Select * from mgmt_system_error_log where module_name = 'UPGRADE-MDM'
    occur_timestamp desc order;

  • Dreamweaver protects data Post (email addresses) when sending forms?

    I would like to know how to prevent Rangers being able to intercept any email addresses on the registration forms (POST) as they are presented on my site. I'm not worried to collect my address on my site, I think that this problem is covered. But I fear that those who register on my site are not giving up their information. How we prevent that?

    Only you can be the judge of whether you should be concerned. If the information is something that you'd happily send by email, there is nothing to worry about. If the information is more delicate, you must store the information directly in a database and then retrieve it directly from the database.

  • SGL and variable U32 are wired to same variable DBL through the structure of the case, block data poster SGL DBL during case U32.

    Hello

    Here, I have attached an example, similar code module is used in our project.

    In this example in the control of two structures business SGL and U32 panels is directly related to the signpost DBL. If I give 4294967295(U32 value of maximum range in the case of forgery under the example) its display 4294967296.

    Please give me the solution to show the correct value of U32 in signpost DBL.

    Thank you

    Wherry

    In your code, 4294967295 is first converted to the SGL (on the edge of the box structure), then to the DBL. But this value may not be exactly converted SGL (due to lack of significant digits).

    You should convert the SGL DBL value in the case of true.

  • How to set http headers when you are using the BridgeTalk HttpConnection object?

    Hello

    I'm doing http post requests from Illustrator ExtendScript (via BridgeTalk) and most of the time it works. However, the documentation on the use of HttpConnection is nonexistent and trying to find a way to set http headers. The HttpConnection object have once requestheaders and responseheaders property so I suspect it's possible.


    By default, post requests are sent with the header Content-Type "text/html", and I would like to replace so that I can use "application/x-www-formulaires-urlencoded" or "multipart/form-data".

    Here's what I have so far:

    var http = function (callback) {}

    var bt = new BridgeTalk();

    BT. Target = "bridge."

    var s = ";

    s += "if (!.). ExternalObject.webaccesslib) {\n";

    s += "ExternalObject.webaccesslib = new ExternalObject ('lib: webaccesslib');" \n » ;

    s += "}\n";

    s += "var html =" "; \n » ;

    s += "http var = new HttpConnection ('http://requestb.in/1mo0r1z1'); \n ";

    s += "http.method = 'POST'; \n » ;

    s += "http.requestheaders ="Content-Type, application/x-www-formulaires-urlencoded,"\n";

    s += "http.request = 'abc = 123 & def = 456'; \n » ;

    s += "var c = 0, t =" "; for (var i in http) {& t = (i +': ' + http [i] +'* '); c ++ ;} t =' FRONT ('+ c +):'+ t;} alert (t); \n » ; Debug: to see what properties and values exist on the http object

    s += "http.response = html; \n » ;

    s += "http.execute (); \n » ;

    s += "http.response; \n";

    s += ' var t =' AFTER:'; for (var i in http) {t += (i +': ' + http [i] +'* ') ;} alert (t);} \n » ; Debug: to see the properties and the values have been set after the execution of

    BT. Body = s;

    bt.onResult = function (evt) {}

    callback (evt);

    };

    bt.onError = function (evt) {}

    callback (evt);

    };

    BT. Send();

    };

    Things to note:

    1. If I try to set the property requestheaders as in my code above, the request fails. If I comment on him, the request succeeds. The default value for requestheaders is not set.

    2 looking at the http after a successful request object, displays the properties of reponseheaders to be on: "KeepAlive, connection, Content-Length, 2, Content-Type, text/html;" "charset = utf-8, Date, Wednesday, June 24, 2015 09:45:40 GMT, server, gunicorn/18.0, sponsored by, https://www.runscope.com, Via, vegur 1.1. Before the query runs, the responseheaders has the value undefined to.


    If someone could help me configure the request (in particular the Content-Type header) headers, I would be eternally grateful!


    Thank you


    UPDATE:

    Using the ExtendScript SDK, I discovered the responseheaders property is an array of this format: ['Connection', 'keep-alive', 'Content-Length', 2, 'Content-Type', ' text/html'...]

    I tried to put the requestheaders for the same format (I've tried both ['Content-Type', "application/x-www-formulaires-urlencoded"] and ['Connection', 'keep-alive', 'Content-Length', 2, 'Content-Type', "application/x-www-formulaires-urlencoded"...]) with no luck



    It solved!

    The key to set the content-type header is set the property http.mime as follows:

    s += "http.mime =" application/x-www-formulaires-urlencoded '; \n » ;

    Also to be complete, you can add your own custom steps headers:

    s += "http.requestheaders = ["My-sample-Header","some value"]; \n » ;

  • Query HTTP POST.vi delay

    Hello world

    I use POST.vi range of HTTP Client through my demo without any problems (100ms between demand response) except a REST API that creates delay 5s.

    When I use put up-to-date POST HERE with the same REST API example, I get a few 100ms response.

    I can not gen in the POST.vi because it is password protected.

    I used Wireshark to debug, and set the HTTP request header in the POST.vi way it is int taken it from the sample with the result of 100ms delay.

    Using curl on ubuntu also leads to 100ms delay.

    I use POST.vi as a buffer: so url Specifies the IP address of the device with the REST API and the buffer transports data in JSON format.

    Not sure which could create this delay in POST.vi?

    Thanks for any idea.

    The problem was not really in the POST.vi, while it has been resolved now.

  • Impossible to get data of Httpconnection and analyze these data on the real device

    Hello

    I use a Blackberry 9000 "BOLD" device. I get xml using the Http connection. My Simulator, it works fine. (Note that I'll have to keep MDS - CS run in HTTP request).

    but when I install the application on the device it shows only the UI elements. No data is downloaded from HTTP connection.

    Do I have to apply all the settings on the device? Please suggest.

    Thank you

    Aktaion.

    Make sure that properly define the connection string.

    There is a very good guide here: http://www.localytics.com/blog/post/how-to-reliably-establish-a-network-connection-on-any-blackberry...

  • vCenter Orchestrator HTTP API: POST request error 400 1032

    I'm trying to start a workflow via a POST request to the vCenter Orchestrator API. When I run the same workflow with a GET request, there is no problem and I get the following result in the localhost_access_log.current_date.txt:

    [src_ip_address] - [13/Oct / 2015:04:46:00 + 0000] "GET vco/api/flux/af83cf34-6a00-45b5-946e-0d44ece508bb/exécutions/HTTP/1.1" 200 272

    However, when I run a POST with the following parameters:

    restMethod: POST

    restEndpoint: https://[dest_ip_address]:8281

    restPath: / vco/api/workflows/af83cf34 - a 6, 00-45 b 5 - 946e - 0d44ece508bb/executions /

    user: [username]

    content: {"parameters": [{'name': 'name1', 'type': 'string', 'value': {'chain': {"value": "Value1"}}, 'field': 'local'}]}

    contentType: application/json

    accept: application/json

    I have the following error in localhost_access_log.current_date.txt:

    [src_ip_address] - [13/Oct / 2015:03:53:39 + 0000] "POST vco/api/flux/af83cf34-6a00-45b5-946e-0d44ece508bb/exécutions/HTTP/1.1" 400 1032

    And the output on the client side:

    {Success = no, ResponseHeader = {null = HTTP/1.1 400 Bad Request, Server = Apache-Coyote/1.1 Content-Length = 1032, Content-Language = EN, connection = closed, Date-Wed, 13 Oct 2015 Message = Bad Request, ReasonPhrase is Bad Request, StatusCode = 400}}

    I'm in vCenter Orchestrator 5.5. There is no output to the server.log file. I didn't have a chance, researching the 400 1032' error number. [dest_ip_address] is HTTPS. Can anyone help clarify this?

    The command line below seems to work for me using the cmd terminal Windows:

    curl u - ikv name h ' Accept: application/json ' h ' Content-Type: application/json "d" {\"parameters\":[{\"value\":{\"string\":{\"value\":\"value1\"}},\"type\":\"string\",\"name\":\"name1\",\"scope\":\"local\" "}]}" x POST https://ip_address:8281/vco/api / stream/af83cf34-6a00-45b5-946e-0d44ece508bb/executions

    Note that the double quotes inside the body of the request are preceded by the backslash character.

  • How to send a document in net. HTTP.request as a POST variable?

    I have read and reread the doc on the net. HTTP.request and he says I can pass an argument to oRequest, but I failed to pass in the current document, which is what I want to do.

    I tried app.activeDocs [0], or the encoding of a string, but if he makes the call with no error, nothing is sent.

    ORequest must be a single document, or a variable consisting of name-value pairs? How to send multiple parameters to a POSITION otherwise?

    I did very well with the call using GET, but when I tried to send the document as a GET variable, I did nothing either.

    I send to an end point of LiveCycle REST so either POST or GET is fine.

    Thank you!

    Validating the document current is simple * provided * your script runs outside the context of the document (i.e. in the console or a script to the folder level). There is no access to scripts of doc-level for obvious reasons.

    For example, put this in the console JS OCCURS the current file to a URL:

    Net.HTTP.request ({}

    cVerb: 'POST',

    cURL: "http://localhost/submit.php."

    oRequest: Collab.documentToStream (this);

    oHandler: {}

    answer: function (msg, uri, err) {}

    If (err! = undefined) app.alert (msg);

    }

    }

    });

    Your problem talking to a vanilla Web service, is that you can send the RFC1867 delimiters (i.e. the form apply for "multipart/form-data") that the ReadStream object is not a method of concatenation in the JSAPI Acrobat. It's also how you would usually precede other fields in the form, but if you are careful with your codes side server that you can send to save them as GET parameters in cURL. Normally, you'd be polite and passed a context of Type in the table of aHeaders header - it won't matter for the transmission process, but will allow your webservice predict what that heck he was sent.

    Your webservice will then read the raw data. PHP for example, you will get nothing in the $_FILES global, but you can grab the PDF by reading all of the input buffer, with the line:

    $pdf = file_get_contents() ("php://input");

    If this line was in the server script which was the JS code above, the variable $pdf will contain an exact binary copy of the currently opened document.

  • Simple HTTP post

    Does anyone know of a document/tutorial that shows you how to make a post of simple http form from a flex application?
    I guess it's possible to do a http post to a ColdFusion page that uses only the usual FORM variables to receive the data.

    After seeing this it would make life a lot easier to create "rich forms" in flex instead of DHTML, javascript & CSS.

    I see many examples of data by pulling in a flex front end, but not much focus on sending data.

    See you soon

    Simon

    I took this example and he wrote style CF.

    Works like a charm...

    See you soon...

Maybe you are looking for

  • Firefox works well on a lg34c

    I was just wondering how it works. Also I can't get to the app store through this browser

  • Re: Tecra A10 - 1 5, Windows 8 is not compatible?

    Dear SirWindows 8 upgrades very well for example drivers etc for this model youIan

  • BSOD on Satellite C660-1RR

    Hi, my laptop, Toshiba Satellite C660-1RR, has terrible problems. First of all, the blue screen (BSOD) appears, and then the laptop stops or restarts again and again. Then closed, it only opens after hours later. When turned on, it only lasts for 5 m

  • Find and replace variables

    Hello world Setup I have a line that connects two cycles in two different VI. The vi share the queue by a reference. Now that I changed the format of the queue of the enum element to a cluster of enum and date my queue reference has changed as well.

  • Problems of CQ58-301SA

    Hello About 3 months ago I bought this laptop. I used only twice and now I want to sell it. However, I have a problem. Whenever I run the HP Wizard and try to get into the recovery environment I wonder whether or not I want to restart but when I choo