http-post

500 Internal server error Android HttpPost file upload

大兔子大兔子 提交于 2019-12-12 02:23:51
问题 Lately I've noticed I get this error when I try to upload an image to my server using HttpPost, the code I use in Eclipse is this: HttpPost httpPost = new HttpPost((String) params[0]); Uri uri = (Uri) params[2]; String fileName = getFileName(uri); if (fileName == null) fileName = "image"; InputStream inputStream = getContentResolver().openInputStream(uri); HttpEntity mpEntity = MultipartEntityBuilder.create().addPart("place", new StringBody((String) params[3])).addBinaryBody("appuploadfile",

Java equivalent of curl post request with image and text

 ̄綄美尐妖づ 提交于 2019-12-12 02:23:51
问题 I'm trying to write java code to do exactly what this command does: curl -F "image=@image.jpg" -F "param1=some-value" -F "param2=some_value" http://example.com I'm currently trying something like this: HttpClient httpClient = HttpClientBuilder.create().build(); HttpPost poster = new HttpPost("http://example.com"); MultipartEntityBuilder mpEntityBuilder = MultipartEntityBuilder.create(); mpEntityBuilder.addPart("param1", new StringBody("some-value")); mpEntityBuilder.addPart("param2", new

ASP.net C# can't read posted form element

血红的双手。 提交于 2019-12-12 01:59:25
问题 On my master page I have: <form id="ReportForm" action="HelpAsk.aspx" method="post"> <input type="hidden" id="HiddenReport" type="text" /> </form> This is outside any server tags, just before the tag. Jquery submits this form when a button on the page is clicked somewhere: function SendReport() { $("#HiddenReport").val("<html>" + $("html").html() + "</html>"); $('#ReportForm').submit(); } But whatever I try, I can't get my receiving page to read that data: NameValueCollection nvc = Request

Issue when using InstallCert For SSLCertification

大兔子大兔子 提交于 2019-12-12 01:29:43
问题 I was trying to send a post request on a url from server then it showed following errors javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Then I found about InstallCert.java( https://www.cs.ucsb.edu/~pconrad/cs56/examples/ldap/SimpleQuery/InstallCert.java ) which will allow my host and port to send the request. But

How do I encode binary file data to ISO-8859-1 to attach to the body of an HTTP post message

时光怂恿深爱的人放手 提交于 2019-12-12 01:02:42
问题 I'm trying to convert the full string of bytes from a file opened in binary mode to a string encoded in the ISO-8859-1 character set. My understanding is that by converting to ISO-8859-1 all binary information from the file is retained which is why it is being converted to that format. Is this a valid statement? I'm working in C++ (Visual Studio 2017) building an executable to be used on the Windows platform. I'm not experienced in HTTP programming. I have prototype code written in PowerShell

HTTP Post delayed until online

随声附和 提交于 2019-12-12 00:54:49
问题 The code I currently have submits data successfully to a database when there is a network connection. My app is one that would be used outdoors, frequently in places were cell service is very poor. My question is what would be the best way to delay the HTTP Post until there is an active network connection? Should I create a service that is run if there is no connection that is alerted when a connection is available? The data transmitted is small, around a kilobyte, so I could just have the

Can't send a correct POST request in Java (Android Studio)

旧街凉风 提交于 2019-12-12 00:36:47
问题 I'm creating an app for asking/answering questions. I have a problem with POST request when I ask questions. I've tried to use something like this in terminal curl -H "Content-Type: application/json" -d '{"firstName":"Chris", "lastName": "Chang", "email": "support@mlab.com"}' http://your-app-name.herokuapp.com/contacts and it worked good. But when I try to send a POST request in AndroidStudio my parameters (such as name, lastname, email and etc) won't send. I tried to use https://github.com

why get requests are working, but post are not in the java servlets

半世苍凉 提交于 2019-12-12 00:34:23
问题 I have a servlet, I call it from a get request, it works, good, but when i call it using this post request private static void doPostToMultiPart() throws URISyntaxException, ClientProtocolException, IOException { HttpClient client = HttpClientBuilder.create().build(); HttpPost httpPost = new HttpPost( "http://localhost:8080/ServletExample1/multipart1"); HttpResponse response = client.execute(httpPost); System.out.println("response code = " + response.getStatusLine().getStatusCode()); String

Sending JSON object to API by using http post

拟墨画扇 提交于 2019-12-11 23:29:22
问题 I want to add header "Content-Type" "application/json". But I am not been able to do this due to api 23 in android. OutputStream os= null; os=httpclient.getOutputStream(); BufferedWriter bw= new BufferedWriter(new OutputStreamWriter(os)); JSONObject jsonobj = new JSONObject(); jsonobj.put("Name","alpha"); jsonobj.put("Status","Active"); jsonobj.put("Type","Admin"); jsonobj.put("Address","beta"); jsonobj.put("Password","333"); jsonobj.put("PhoneNumber",123); bw.write(jsonobj.toString()); os

Processing HTTP Post with Array (no cURL)

风格不统一 提交于 2019-12-11 23:18:05
问题 function do_post_request($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php