http-post

Posting JSON data using AFNetworking 2.0

江枫思渺然 提交于 2019-12-17 06:27:38
问题 I have a web script which accepts JSON string as input through HTTP POST request. I have came across several AFNetworking 1.x example for the same , can anybody please point me or give AFNetworking 2.0 example to do an HTTP POST request to a web script with formatted JSON as input ? Thanks 回答1: after searching docs and trying out some codes I got following as an example AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer =

HTTP POST Returns Error: 417 “Expectation Failed.”

隐身守侯 提交于 2019-12-17 06:20:46
问题 When I try to POST to a URL it results in the following exception: The remote server returned an error: (417) Expectation Failed. Here's a sample code: var client = new WebClient(); var postData = new NameValueCollection(); postData.Add("postParamName", "postParamValue"); byte[] responseBytes = client.UploadValues("http://...", postData); string response = Encoding.UTF8.GetString(responseBytes); // (417) Expectation Failed. Using an HttpWebRequest/HttpWebResponse pair or an HttpClient doesn't

Send POST Request with Data Specified in File via Curl

孤人 提交于 2019-12-17 05:33:13
问题 I need to make a POST request via Curl from the command line. Data for this request is located in a file. I know that via PUT this could be done with the --upload-file option. curl host:port/post-file -H "Content-Type: text/xml" --data "contents_of_file" 回答1: You're looking for the --data-binary argument: curl -i -X POST host:port/post-file \ -H "Content-Type: text/xml" \ --data-binary "@path/to/file" In the example above, -i prints out all the headers so that you can see what's going on, and

How to programmatically send POST request to JSF page without using HTML form?

穿精又带淫゛_ 提交于 2019-12-17 04:35:15
问题 I have very simple JSF bean like shown below: import org.jboss.seam.annotations.Name; @Name(Sample.NAME) public class Sample { public static final String NAME="df"; private String text = "text-test"; public void sampleM(){ System.out.println("Test: "+text); } public String getText() { return text; } public void setText(String text) { this.text = text; } } And JSF form connected with this component: <h:form id="sampleForm"> <h:commandButton id="sampleButton" action="#{df.sampleM()}" value="ok"

Should I URL-encode POST data?

与世无争的帅哥 提交于 2019-12-17 03:47:21
问题 I'm POSTing data to an external API (using PHP, if it's relevant). Should I URL-encode the POST variables that I pass? Or do I only need to URL-encode GET data? Thanks! UPDATE: This is my PHP, in case it is relevant: $fields = array( 'mediaupload'=>$file_field, 'username'=>urlencode($_POST["username"]), 'password'=>urlencode($_POST["password"]), 'latitude'=>urlencode($_POST["latitude"]), 'longitude'=>urlencode($_POST["longitude"]), 'datetime'=>urlencode($_POST["datetime"]), 'category'=

VB.NET - Salesforce POST Request returns 400 Bad Request Error

两盒软妹~` 提交于 2019-12-14 04:25:18
问题 NOTE : I've never written vb.net code before this. I've googled for a solution but did not find anything that worked. I'm trying to get access token from Salesforce. Below code worked just yesterday . And I have no idea why it is not working today. I've tried adding content-type as application/x-www-form-urlencoded but it did not work either. When I use curl I'm able to get access token. Also I'm able to get access token using advanced rest client in google chrome. Any ideas why it is

Can't resolve symbol 'Defaulthttpclient' and 'Httppost' in android

喜夏-厌秋 提交于 2019-12-14 04:21:16
问题 i build a new project.but i have a little problem.i can't use DefaultHttpClient and HttpPost even after i use it in my previous project already. Is there any external librery i have to add? i don't know how can i use both of this. Help me for this issue. My build.gradle apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "22.0.1" defaultConfig { applicationId "Id" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release {

What is the proper way to allow multiple reads of http.Request.Body

非 Y 不嫁゛ 提交于 2019-12-14 03:35:11
问题 I want to access a http.Request 's Body multiple times. The first time happens in my authentication middleware, it uses it to recreate a sha256 signature. The second time happens later, I parse it into JSON for use in my database. I realize that you can't read from an io.Reader (or an io.ReadCloser in this case) more than once. I found an answer to another question with a solution: When you first read the body, you have to store it so once you're done with it, you can set a new io.ReadCloser

form not submitting text box's new value

邮差的信 提交于 2019-12-14 03:12:14
问题 I have a form, whose textboxes are generated via loop and contains its default value. But upon submission, I get its default value and not the value that was just updated. Here is the cshtml code <fieldset> <legend>Module <small>Edit</small></legend> @using (Html.BeginForm("Edit", "Module")) { @Html.ValidationSummary(true) @Html.HiddenFor(m=>m.Id) for(var i = 0; i < Model.Properties.Count(); i++) { @Html.HiddenFor(model=>Model.HiddenProperties[i].Value) <label class="label">@Model.Properties

How to send serialized object to a servlet using Apache HttpClient

天涯浪子 提交于 2019-12-14 02:25:37
问题 I have a Main() class where I serialize an object of a class called Names . I am using Apache HttpClient 's HttpPost() to call a servlet . public static void main(String[] args) { Names names = new Names(); names.setName("ABC"); names.setPlace("Bangalore"); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("Name.txt")); out.writeObject(names); out.close(); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://localhost:6080/HttpClientGson