Sending long HTTP POST with URLEncodedPostData
Hi all.
I try to call a REST service that receives the parameters string POST and I did it successfully with URLEncodedPostData until I needed to send a 'long' String param (around 40 K. It is a single HTML page). Then, I got a 500 error from the server code. Should I consider a particular case after a certain size or would it be a server error?
This is how to create the URLEncodedPostData object
URLEncodedPostData data = new URLEncodedPostData("UTF-8", false); data.append("email", user.getEmail()); data.append("password", user.getPassword()); data.append("subject", subject); data.append("content", content);
... and then send the MESSAGE
ConnectionFactory conn = new ConnectionFactory(); ConnectionDescriptor desc = conn.getConnection(url); c = (HttpConnection) desc.getConnection(); c.setRequestMethod(HttpConnection.POST); c.setRequestProperty(HttpHeaders.HEADER_CONTENT_TYPE,data.getContentType()); c.setRequestProperty(HttpHeaders.HEADER_CONTENT_LENGTH,String.valueOf(data.getBytes().length)); c.setRequestProperty(HttpHeaders.HEADER_ACCEPT, HttpHeaders.CONTENT_TYPE_APPLICATION_XML); OutputStream os = c.openOutputStream(); os.write(data.getBytes()); os.flush(); os.close(); int rc = c.getResponseCode();
RC is 500 so that is bad, but if I cut the content to
data.append("content", content.substring(0,100));
It works very well. That's why I think that it a problem with the MESSAGE size.
Any ideas?
I just checked and I can confirm that the problem was not on the device but on the server.
The content is sent completely to the right server by using the code written before, but the server does not handle because he has size limitations.
Thank you all for your comments. Bravo for you
Tags: BlackBerry Developers
Similar Questions
-
Hello
I use Orchestrator version 4.2.1 build 555
And I do an HTTP Post to a server that only accepts SSL v3
The code is easy:
//Auto-generated script var urlObject = new URL(url); result = urlObject.postContent(content) ;
But that's what I get as error:
HTTP GET error: sun.security.validator.ValidatorException: building way PKIX failed: sun.security.provider.certpath.SunCertPathBuilderException: could not find the path of valid certification for target asked
If I do a post manual to this url with the content of the message succeeds.
Is it possible that the Orchestrator can only use SSL v2?
And is there a way I can make the post HTTP messages with SSL3
This is not the right place to import the certificates from the remote host.
Please open the vCO Web Configurator, go to the tab 'network' (not 'server certificate' tab), and then select the 'SSL Trust Manager' tab in the right pane.
There is a labeled text box "URL from which import a certificate". Provide the remote host/port (IE. ( https://10.23.30.40:8281), and then click the "Import" button on the right. Then restart the vCO server and try again the POST.
-
Send a PDF form via HTTP Post: Newbie Questions
Hello
I am completely new to PDF forms, so I was finding the documentation and the overwhelming options.
I'm hoping to get directed to the documentation/tutorials/examples that I really need.
I want to build a 'proof of concept' for my boss. I would like to include a screen in our webapp Java (JSP & spring) where either a PDF form is incorporated or is accessible via a link.
I have
- Standard Adobe Acrobat Distiller X license
- Adobe Acrobat X Standard
- Microsoft Office 2010
I made a little, the form of Microsoft Word 3 field. I then he converted via distill into a PDF form.
I then found this document on how to submit a PDF form to a component side Server:
http://acrobatusers.com/tutorials/form-submit-e-mail-Demystified
My big problem with this document, is not an example, nor an example of what is happening in an HTML page complete. Because I I have a few questions:
- I see such an example somewhere?
- The result of the call to the javascript function doc. SubmitForm (urlToMyServerSideComponent) go in a script tag on the HTML page as other javascripts?
- Can I submit the function from an HTML button run or I put a button 'send' the PDF form?
- Do I need Adobe LiveCycle to create a PDF form with a button "submit"? Free versions?
- Can I send via HTTP POST?
- Do I need Adobe LiveCycle to create a PDF form with a digital signature?
- Is there a document/tutorial that fits where I want to? (Please no books, I am tyring to show to my boss that this is something which can be done in a reasonable amount of time, no time to get and go through a book).
Thanks in advance for things which make me pointed in the right direction
Steve
This seems to imply that I can do a such acroform without using an application or can I use an application with an option to write code by hand. Am I wrong? If yes could tell me on the document from the beginner to learn how to do this? I have acrobat, but I don't have the 'send to server' option in the menu to distribute.
No, you would use Acrobat to add the button and configure. As said earier, you want not to use distribute the form for this type of shape. Simply add a button on one of the pages of the PDF and give a mouse action upward to "submit a form":
The video tutorial contains more information on the treatment of the submission on the server. Again, do not use the option to distribute the form in Acrobat.
-
sign the document with 'Draw my signature' and send it via http-post
Hello
I have a pdf document with a signature field. When im opening with AcrobatReader XI, I can sign / Place Signature / draw my signature. I can't 'save a copy '. It works pretty well.
Now, I place a button in the pdf document to be sent via http post to a given address. When I now open this PDF in the XI AcrobatReader, trying to sign. I can only do this with sign / Place Signature / use a certificate. But there is no way to "draw my signature."
Did I miss an option to do this? Pls tell me if he has a chance to sign the document with 'Draw my signature' and send it via http-post.
Or is this part of the concept? When I'm looking for a solution, I found EchoSign electronic signature.
What is available depends on how the as is put in place. If you include a button with an action of type 'Submit form' and/or reader - enable the form, then e-signature (signature of drawing) will not be available in the player. If the document is compatible player then digitally signing will. So for what you want, do not Reader-enable the document and you can use the submitForm JavaScript method to submit. The site that has the JavaScript documentation was not available at the time I wrote this, but post again if you need help with that.
-
Help with JSON HTTP Post request
Still fairly new to QT so I try to send a query with some json http post, I'm pulling the json to a file and which seems to work fine but I get a http 500 error. I want to just make sure that my code is correct before contacting the company that webservice I use here is my code:
JsonDataAccess jda; QVariant list = jda.load(QDir::currentPath() +"/app/native/assets/jsonData/myjson.json"); qDebug()<
- post(request, list.toByteArray());
I have a feeling that I'm passing in json data in the wrong post method. Any help is appreicated
Hello
You send an empty server string because list.toByteArray () returns an empty string.
You must save the QByteArray list;
QByteArray result; jda.saveToBuffer(list, &result); // and then QNetworkReply *reply = networkAccessManager->post(request, result);
or
Simply load the json with QFile file
QFile file(YOUR_JSON); if (!file.open(QIODevice::ReadOnly)){ qDebug() << Q_FUNC_INFO << file.errorString(); return; } QByteArray result = file.readAll(); file.close() QNetworkReply *reply = networkAccessManager->post(request, result);
Hoe it helps
-
Hi all
I have an application where I can access the net server point of LabVIEW via the HTTP protocol to send the data. My application works fine when I run it on XP, and also sometimes on cRIO. I'm writing and reading files to store and read data from the server.
When I do my application executable and deployed on cRIO I am constantly 7 error that says "Error in the node library function to call at the POST vi LabVIEWHTTPCLIENT".
After getting this error if I try to run the my new project the crio (not through exe) I keep getting the same error. This means once the executable file is deployed on the crio, I get the error in my project application which was working fine before you deploy the executable file.
7 occurs very frequently. and I am unable to find the reason. I gave all the paths in the constant form located on crio and files accessible also when the application is run.
Is someone can you please help me what this error 7?
as a result, that it is bound to the HTTP POST vi method...
How can it be fix?
Its quite urgent...
Thanks in advance.
Solution is provided by the NOR... Vi POST method missing two files that need to be there in the startup of the CRIO.insted folder there is in the system folder. That's why when running the exe that the startup on crio application it gives error as the files are not there. The fix for this HTTP POST vi update isn't out yet EITHER.
-
Problem when using SOAP requests with HTTP POST function
Hello!
Using the vi of HTTP POST to send SOAP requests to a device, I encountered a problem.
Take care of the HTTP header for you HTTP POST vi and defines the type of 'content' as "Content-Type: application/x-www-formulaires-urlencoded. Who is considered to be 'non-soap' requests by some Web servers.
Standards W3C says in this case, you should be content-type: "application/soap + xml".
Link to the page to W3C standard: http://www.w3.org/TR/soap12-part0/#L26866
That is possible to update this feature in a future release so that programmers can choose (or type) the necessary content type?
Have you tried "Add header" to change?
http://zone.NI.com/reference/en-XX/help/371361L-01/lvcomm/http_client_addheader/
-
A form of Google with http POST VI
Dear LabVIEW forum,
I'm filling out a very simple form of Google consisting of 4 text fields named AI0 AI1, AI2 AI3.
I use the http POST provided by LabVIEW VI:
When I run this, a new row is added to the answer sheet, but values do not appear, with the exception of the timestamp.
What I am doing wrong?
Thank you!
Hello
I had a quick look at the form and text next to the entry boxes is AI0... but the names of the input text boxes aren't AI0 etc.. You may need to get the page first and then scan the page for the name of the entry.
Mike
-
Sending parameter using the METHOD (HTTP POST = PROBLEM WEBSERVICE)
Hello world
I need help here
I tried 1 week to the code to send the parameter but the error still result
It sends no parameter at all the
Heres my PPC
ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app) { m_pTranslator = new QTranslator(this); m_pLocaleHandler = new LocaleHandler(this); bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged())); // This is only available in Debug builds Q_ASSERT(res); // Since the variable is not used in the app, this is added to avoid a Q_UNUSED(res); onSystemLanguageChanged(); QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); qml->setContextProperty("MyApp",this); // Create root object for the UI AbstractPane *root = qml->createRootObject
(); // Set created root object as the application scene app->setScene(root); } void ApplicationUI::post(const QString &fullName, const QString &email, const QString &password) { QNetworkAccessManager connection; QUrl url("http://www.rws.rajaspot.com/rs_usermanagementclient.php"); QNetworkRequest req(url); //url.addQueryItem("parameter", "14"); QByteArray postData; postData.append("method=rsnewuser&").append("fullName="+fullName).append("email="+email).append("password="+password); QNetworkReply* reply = connection.post(req, postData); bool ok = connect(reply, SIGNAL(finished()), this, SLOT(postFinished())); Q_ASSERT(ok); Q_UNUSED(ok); } /** * PostHttp::onGetReply() * * SLOT * Read and return the http response from our http post request */ void ApplicationUI::postFinished() { QNetworkReply* reply = qobject_cast (sender()); /* QString response; if (reply) {*/ if (reply->error() == QNetworkReply::NoError) { QString result = reply->readAll(); /*const int available = reply->bytesAvailable(); if (available > 0) { const QByteArray buffer(reply->readAll()); response = QString::fromUtf8(buffer); }*/ } else { int errorCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); qDebug() << errorCode << endl << reply ->errorString(); } reply->deleteLater(); } void ApplicationUI::onSystemLanguageChanged() { QCoreApplication::instance()->removeTranslator(m_pTranslator); // Initiate, load and install the application translation files. QString locale_string = QLocale().name(); QString file_name = QString("UsernamePHP_%1").arg(locale_string); if (m_pTranslator->load(file_name, "app/native/qm")) { QCoreApplication::instance()->installTranslator(m_pTranslator); } } Heres my hpp
#ifndef ApplicationUI_HPP_ #define ApplicationUI_HPP_ #include
namespace bb { namespace cascades { class Application; class LocaleHandler; } } class QTranslator; /*! * @brief Application object * * */ class ApplicationUI : public QObject { Q_OBJECT public: ApplicationUI(bb::cascades::Application *app); virtual ~ApplicationUI() { } public: Q_INVOKABLE void post(const QString &fullName, const QString &email, const QString &password); Q_SIGNALS: void complete(const QString &info); private Q_SLOTS: void postFinished(); private slots: void onSystemLanguageChanged(); private: QTranslator* m_pTranslator; bb::cascades::LocaleHandler* m_pLocaleHandler; }; #endif /* ApplicationUI_HPP_ */ and this is my my main.qml
Button{ id : button text : "Register" onClicked: { MyApp.post(tf1.text,tf2.text,tfpass.text) } horizontalAlignment: HorizontalAlignment.Center }
I need to send the parameter to http://www.rws.rajaspot.com/rs_usermanagementclient.php
but its like divider by 2, the parameter 'method = rsnewuser' and the content is fullName, email, and password
What a success, it will show on http://www.rws.rajaspot.com/rs_userclient.php but I try this error code again
any ideas what should I do?
Thank you
I mean not to define QNetworkAccessManager inside the function.
For example:
Declare the pointer to QNetworkAccessManager in your header file (all)
QNetworkAccessManager *connection;
and then set it in the constructor of the app inside the function you or you. In the second case, you must remove QNetworkAccessManager pointer after postFinished. (connection-> deleteLater())
connection = new QNetworkAccessManager(this);
and the full code of the POST function
...post(const QString &fullName, const QString &email, const QString &password) { QUrl url("http://www.rws.rajaspot.com/rs_usermanagementclient.php"); QUrl postParams; postParams.addQueryItem("method", "rsnewuser"); postParams.addQueryItem("fullName", fullName); postParams.addQueryItem("email", email); postParams.addQueryItem("password", password); QNetworkRequest req(url); req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply* reply = connection->post(req, postParams.encodedQuery()); bool ok = connect(reply, SIGNAL(finished()), this, SLOT(postFinished())); Q_ASSERT(ok); Q_UNUSED(ok); }
It may be useful
-
HTTP POST works does not as expected
I can't understand why the POST with data works when I use Firefox, but not when sent from the BlackBerry. The only difference seems to be that the BlackBerry less sends the headers, but it's all legal HTTP.
It's TCP data are sent to the server (from recorder package):
----------------------------------
HTTP/1.1 POST/page
Host: localhost
Connection: close
Content-Length: 8test = abc
----------------------------------
That sounds about right. However, the Web Server table $_POST (PHP) is empty.
Code follows:
HttpConnection c = (HttpConnection)Connector.open(connectionString); c.setRequestMethod(HttpConnection.POST); DataOutputStream out = c.openDataOutputStream(); URLEncodedPostData postData = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, true); postData.append("test", "abc"); System.out.println("requestData: " + new String(postData.getBytes())); out.write(postData.getBytes()); //out.flush(); c.getResponseCode(); InputStream is = c.openDataInputStream(); LineReader lr = new LineReader(is); while(true) { try { byte[] arr = lr.readLine(); System.out.println("Line: " + new String(arr)); } catch(EOFException e) { break; } }
Everyone knows about similar problems using POST?
See you soon,.
Pav
Update:
-J' tried this on 2 servers Web (Apache + PHP) unrelated, both have the same problem.
SOLVED!
I tried to put different headers that Firefox sends inside the request of BB and it does the job:
c.setRequestProperty ("Content-Type", "application/x-www-formulaires-urlencoded");
Hope it saves someone out there a lot of frustration :-)
-
/ * moved from answers Feedback * /.
I have a question regarding windows mail. I was send and receive mail with no problems until last Thursday. I can still receive mail, but I can not send. My email is with bellsouth.net and comes in my computer through windows Messaging. I spent an hour and a half on the phone with bellsouth, and they say that the problem is with my windows mail. I tried to use a restore date, and that did not help either. I will post a copy of this message, as I keep getting. Your server suddenly put an end to the connection. The possible causes for this include server problems, network problems, or a long period of inactivity. Object 't', counts: 'mail.bellsouth.net', server: 'mail.bellsouth.net', Protocol: SMTP, Port: 25, secure (SSL): no, error number: 0x800CCC0F thanks for any help.Sometimes, WinMail settings get screwed up and you must remove the account and then add it back back. Make sure first that the antivirus software not interfere (see www.oehelp.com/OETips.aspx#3). Delete your account completely, then close WinMail. Then compact and repair the database of WinMail (see www.oehelp.com/WMUtil/). Add your account to mail back once again, and then make sure you have the correct settings under Tools | Accounts | Mail | Properties | Servers and | Advanced to what AT & T Specifies to WinMail (or OE). Then see if it works.
Steve
-
Cannot send the UDP datagram with device 8320 (V4.2.2.180)
There is a post says "Cannot send the datagram UDP with JDE 4.5" to
In the emulator of JDE4.2 it really works, but he meets the same problem in the blackberry8320 (V4.2.2.180) device, get the same java.io.IOException (detailMessage = null) to the send() operation;
I looked in the (accessible via wifi) PC with a tool named Sockettool (it can create the client and Server TCP/UDP), it can be connected to the emulator and receive datagrams sent to the emulator, but can not be connected to device.
Is this a problem related version too?
Appreciate if you can share your experience with datagram connection to the device.
Here is my code:
Emulator: host = "udp://iport1; port2.
Feature: host = "udp://iport1; port2 /; = wifi interface.
try { udp_client = (DatagramConnection) Connector.open(host); byte[] data = {65,66,67,68}; int len = data.length; dg_out = udp_client.newDatagram(data, data.length); udp_client.send(dg_out); udp_client.close(); }catch (Exception e) { System.out.println("UDP Exception:"+e.getMessage()); }
If the application is able to send and receive UDP traffic in the BlackBerry Simulator, but not on a BlackBerry real pocket computer the first thing to check is to check that your carrier supports. Several carriers do not support UDP traffic or restrict to specific ports or data types. This can cause exceptions or make it appear that the application will silently fail (carrier is just dropping packets).
-
Transport http - problem with timeout
Hello
I have a Bussines services that uses the Http transport and its configured with the ending "http://90.56.154.45:989 / offline1".
It's the rest of the config:
/************/
General configuration
Type of service no matter what XML Service
Transport configuration
Http protocol
Load balancing algorithm no
Endpoint URI
http://90.56.154.45:989 / offline1
Retry Count 0
Retry interval iteration 0
Start Application Yes errors
Configuration of HTTP Transport
Timeout 5
Query HTTP POST method
Authentication no
Proxy server
Follow redirects HTTP DISABLED
Use segmented Mode streaming
Content of message, Configuration management
MTOM/XOP support disabled
Page attachments to disk no.
/*************/
When I try to sbconsole, the connection lasts about 3 minutes. Why not meet the deadline set to 5 seconds?
Thank you very much, greetings.But the setting of timeout (timeout = 5 sg) still not come into force. It may be a possible bug?
Only the timeout setting is actually to READ timeout. So if the target server takes longer than the number of seconds that you have configured in the timeout parameter, then only this setting will take effect. Like currently, you are not able to even connect (connect timeout came into picture), that's why READ timeout isn't triggering because READ has not even started.
It works as expected and there is no problem with the setting.
Kind regards
Anuj -
HTTPS Post does not work in the OFA Page
Hi all
I created a Page of the OFA, by clicking on button I do next.
//--------------------------------------------------------
private static String contactService(String xmlInputString) throws Exception {}
String outputStr = null;
OutputStream outputStream = null;
try {}
URL url = new URL ("https://wwwcie.ups.com/ups.app/xml/ShipConfirm");
HttpURLConnection connection = () (HttpURLConnection) url.openConnection;
System.out.println ("Customer connection established with" + url.toString ());
Configure the HTTP POST parameters
connection.setDoOutput (true);
connection.setDoInput (true);
connection.setUseCaches (false);
outputStream = connection.getOutputStream ();
outputStream.write (xmlInputString.getBytes ());
outputStream.flush ();
outputStream.close ();
System.out.println ("Http status =" + connection.getResponseCode () + "" + connection.getResponseMessage ());
outputStr = readURLConnection (connection);
System.out.println ("Response..." + outputStr);
} catch (Exception e) {}
System.out.println ("error sending data to the server..." + e.getMessage ());
throw e;
} {Finally
If (outputStream! = null) {}
outputStream.close ();
outputStream = null;
}
}
Return outputStr;
}
//----------------------------------------------------
public static String readURLConnection (URLConnection uc) throws Exception {}
StringBuffer buffer = new StringBuffer();
BufferedReader reader = null;
try {}
reader = new BufferedReader (new InputStreamReader (uc.getInputStream ()));
Letter int = 0;
reader.readLine ();
While ((letter = reader.read ())! = - 1) {}
Letter from buffer. Append ((Char));
}
Reader.Close ();
} catch (Exception e) {}
System.out.println ("could not read from URL:" + try ());
throw e;
} {Finally
If (reader! = null) {}
Reader.Close ();
Reader = null;
}
}
Return buffer.toString ();
}
Now, when I run this JDEVELOPER local it works fine, but when when depolyed on the server, then when I click the button then page gets hanged and it does nothing.
Is there any setting I should do in APPS environment. or anyone had done the same. any help will be appreciated.
Thank you
Vijay chraibiHello
If your code works fine in JDev and it does not work on the instance, then you can trigger SR with Oracle for Ptoduct JDeveloper.
Kind regards
Out Sharma -
Authentication http post VI errors
I am trying to query a web service to third parties non-LabVIEW LabVIEW 2014, using HTTP POST. Using another utility (restclient-ui-3.5-jar-with-dependencies.jar), I checked that URL, user name, password, and query syntax are accurate and are running on the same computer where my VI fails. I must be missing something when translating that to LV, because I get the error 401 (full authentication is required) and also 415 (unsupported media type).
I have attached the configuration file used for the other utility, my VI and an overview of the response from the Web service for the post of the VI. I had to make all anonymous, hide url, user, etc., so it can not really be tested as it is, unfortunately. I tried with & without additional authentication header, with & without Config SSL, etc. You can see the different options on the VI.
Any suggestions?
Thank you very much.
Solved my problem with a combination of different required headers and syntax fixes.
Maybe you are looking for
-
Problem with access point or wireless adapter
Hello world tried to connect to my WiFi, but the convenience store detects that the problem with access point or wireless adapter.The drivers are up-to-date and functioning normally. There were discussions on BIOS but I don't know if I would be able
-
Error-301034 with Toolkit ECU Measurement and Calibration
I get a message error 301034 occurred at MC Daq Initialize when I try to run my program. I checked my measure names are correctly spelled (special case) and the a2l file is a copy of one that is used on other testbed that uses sofa. I copied the a2l
-
Relocation of phones smart blackBerry Twitter App
By mistake I deleted my Twitter app and I can't find it on App World... Any help please
-
I have HP laptop & upgrade windows 7 to windows 8, here I am able to see the camera, if I click it will open and display connect them a camera too in the background I see 3 tools with off mode. How can I open my webcam? You can help it. Not able
-
Assignment of names manually in ASM files
Version of grid infrastructure: 11.2.0.4RDBMS Version: 11.2.0.4When you have an ASM filesystem, you can add a file of data using Method1 or methode2 below.Name the files manually using the method 1 (non - OMF) is not recommended. But I don't remember