http-post

OkHttp Post Body as JSON

天大地大妈咪最大 提交于 2019-11-26 07:26:02
问题 So, back when I was using Koush\'s Ion, I was able to add a json body to my posts with a simple .setJsonObjectBody(json).asJsonObject() I\'m moving over to OkHttp, and I really don\'t see a good way to do that. I\'m getting error 400\'s all over the place. Anyone have any ideas? I\'ve even tried manually formatting it as a json string. String reason = menuItem.getTitle().toString(); JsonObject json = new JsonObject(); json.addProperty(\"Reason\", reason); String url = mBaseUrl + \"/\" + id +

Pure JavaScript Send POST Data Without a Form

爱⌒轻易说出口 提交于 2019-11-26 07:19:00
问题 Is there a way to send data using the POST method without a form and without refreshing the page using only pure JavaScript (not jQuery $.post() )? Maybe httprequest or something else (just can\'t find it now)? 回答1: You can send it and insert the data to the body: var xhr = new XMLHttpRequest(); xhr.open("POST", yourUrl, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send(JSON.stringify({ value: value })); By the way, for get request: var xhr = new XMLHttpRequest(); //

asp.net MVC 4 multiple post via different forms

我是研究僧i 提交于 2019-11-26 06:33:58
问题 Right now I understand if (IsPost){ //do stuff } checks all post methods on that page. However, I have 2 different forms posting 2 different information. These are a login form and a register form. Is there a way I can check IsPost based on which form? For example, if(Login.IsPost){ //do stuff } but how would I define the Login variable? My form looks like: <form id=\"Login\" method = \"POST\"> I have tried: var Login = Form.[\"Login\"] it did not work. I will appreciate any help. Thanks. 回答1

Get all variables sent with POST?

一笑奈何 提交于 2019-11-26 06:28:52
问题 I need to insert all variables sent with post, they were checkboxes each representing an user. If I use GET I get something like this: ?19=on&25=on&30=on I need to insert the variables in the database. How do I get all variables sent with POST? As an array or values separated with comas or something? 回答1: The variable $_POST is automatically populated. Try var_dump($_POST); to see the contents. You can access individual values like this: echo $_POST["name"]; This, of course, assumes your form

Logging POST data from $request_body

雨燕双飞 提交于 2019-11-26 06:18:47
问题 I have my config setup to handle a bunch of GET requests which render pixels that work fine to handle analytics and parse query strings for logging. With an additional third party data stream, I need to handle a POST request to a given url that has JSON in an expected loggable format inside of it\'s request body. I don\'t want to use a secondary server with proxy_pass and just want to log the whole response into an associated log file like what it does with GET requests. A snippet of some

How to do a HTTP Post in Android?

喜欢而已 提交于 2019-11-26 05:56:09
问题 i am new to android app development, what i need is i have two textbox username and password,it will post to server and check it with the DB using a php page, if the login success then go to next screen else show a msg box showing login error how can i do that? public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(\"http://google.com\"); EditText tw =(EditText) findViewById(R.id.EditText01); try {

Fill fields in webview automatically

落爺英雄遲暮 提交于 2019-11-26 05:29:46
问题 I have seen this question floating around the internet, but I haven\'t found a working solution yet. Basically, I want to load my app and press a button; the button action will then fill in a username and password in a website already loaded in the webview (or wait for onPageFinished). Finally, the submit button on the login page will be activated. From what I understand this can be done by doing a java injection with the loadUrl(javascript), but I don\'t know what the java commands would be

Post a x-www-form-urlencoded request from React Native

 ̄綄美尐妖づ 提交于 2019-11-26 05:27:37
问题 I have some parameters that I want to POST form-encoded to my server: { \'userName\': \'test@gmail.com\', \'password\': \'Password!\', \'grant_type\': \'password\' } I\'m sending my request (currently without parameters) like this var obj = { method: \'POST\', headers: { \'Content-Type\': \'application/x-www-form-urlencoded; charset=UTF-8\', }, }; fetch(\'https://example.com/login\', obj) .then(function(res) { // Do stuff with result }); How can I include the form-encoded parameters in the

Objective C: How to upload image and text using HTTP POST?

孤者浪人 提交于 2019-11-26 05:19:32
问题 I\'ve successfully created two different methods where each of them can upload either an image or text. But I am having problem writing a method that can post both text and image simultaneously! // Here\'s my new method witch worked fine thanx to @sgosha: - (void) upload { NSString *urlString = @\"http://www.examplescript.com\"; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@\"POST\"];

Issue reading HTTP request body from a JSON POST in PHP

二次信任 提交于 2019-11-26 04:54:04
I'm writing a script that is registered as an endpoint for a webhook. I know that it's successfully registered because I'm writing the header of every request to my server logs. Here's a sample: Content-Type: text/xml; charset=UTF-8 User-Agent: Jakarta Commons-HttpClient/3.1 Host: =={obfuscated}== Content-Length: 1918 The API that I've registered with is POST-ing a JSON object to my script, and I'd like to parse that object using PHP. As you can see from the request header, there's a nice big fat JSON object waiting to be parsed. It seems straightforward, but it hasn't been. At first I tried