XMLHttpRequest to Post HTML Form

The POST string format is the following: name=value&name2=value2&name3=value3 So you have to grab all names, their values and put them into that format. You can either iterate all input elements or get specific ones by calling document.getElementById(). Warning: You have to use encodeURIComponent() for all names and especially for the values so that possible & … Read more

Uploading Image via POST in Objective C

Objective-C -(void)saveImageToServer { // COnvert Image to NSData NSData *dataImage = UIImageJPEGRepresentation([UIImage imageNamed:@”yourImage”], 1.0f); // set your URL Where to Upload Image NSString *urlString = @”Your URL HERE”; // set your Image Name NSString *filename = @”YourImageFileName”; // Create ‘POST’ MutableRequest with Data and Other Image Attachment. NSMutableURLRequest* request= [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; … Read more

Open new window by POST using h:commandButton

The only non-JS way is to set target=”_blank” in the parent <h:form>. <h:form target=”_blank”> … <h:commandButton value=”Open in new Window” /> </h:form> This however affects all non-ajax(!) actions which are performed in the very same form. So if you’re smart, make the action which shouldn’t open in a new window an ajax action. However, ajax … Read more

Reading FromUri and FromBody at the same time

A post body is typically a URI string like this: Message=foobar&TestingMode=true You have to make sure that the HTTP header contains Content-Type: application/x-www-form-urlencoded EDIT: Because it’s still not working, I created a full example myself. It prints the correct data. I also used .NET 4.5 RC. // server-side public class ValuesController : ApiController { [HttpPost] … Read more

HTTP POST request in Inno Setup Script

Based on jsobo advice of using WinHTTP library, I came with this very simple code that does the trick. Say, you want to send serial number for verification just before the actual installation starts. In the Code section, put: procedure CurStepChanged(CurStep: TSetupStep); var WinHttpReq: Variant; begin if CurStep = ssInstall then begin if AutoCheckRadioButton.Checked = … Read more

How to upload multipart form data and image to server in android?

If like me you were struggling with multipart upload. Here’s a solution using 95% of code from this Android snippet. public String multipartRequest(String urlTo, Map<String, String> parmas, String filepath, String filefield, String fileMimeType) throws CustomException { HttpURLConnection connection = null; DataOutputStream outputStream = null; InputStream inputStream = null; String twoHyphens = “–“; String boundary = … Read more

Using HttpClient and HttpPost in Android with post parameters

You can actually send it as JSON the following way: // Build the JSON object to pass parameters JSONObject jsonObj = new JSONObject(); jsonObj.put(“username”, username); jsonObj.put(“apikey”, apikey); // Create the POST object and add the parameters HttpPost httpPost = new HttpPost(url); StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8); entity.setContentType(“application/json”); httpPost.setEntity(entity); HttpClient client = new DefaultHttpClient(); HttpResponse … Read more

Posting JSON data using AFNetworking 2.0

after searching docs and trying out some codes I got following as an example AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; NSDictionary *params = @ {@”user” :txtUserName, @”pwd” :txtPwd }; [manager POST:URL_SIGNIN parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@”JSON: %@”, responseObject); } failure: ^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@”Error: %@”, error); }]; Also … Read more

Access POST values in Symfony2 request object

The form post values are stored under the name of the form in the request. For example, if you’ve overridden the getName() method of ContactType() to return “contact”, you would do this: $postData = $request->request->get(‘contact’); $name_value = $postData[‘name’]; If you’re still having trouble, try doing a var_dump() on $request->request->all() to see all the post values.