http-post

How do I POST a buffer of JSON using libcurl?

删除回忆录丶 提交于 2019-12-03 12:36:32
问题 My C++ program currently invokes curl through a pipe ( popen("curl ...") ) to POST a file of JSON data to a web server. This has obvious performance limitations due to the need to save the JSON to a file and invoke curl in a subshell. I'd like to rewrite it to use libcurl, but it is not clear to me how to do this. The command line I pass to popen() is: curl -s -S -D /dev/null -H "Content-Type: application/json" -X POST -d file-of-json http://server/handler.php The JSON data (about 3K) is

Post Json object data to get Json array response using volley in android

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 12:29:59
I need to post JSONObject (using Volley ) to a web-service which is returning the response in JSONArray format. Here is what I have tried so far. final JSONObject requestJsonObject = new JSONObject(); requestJsonObject.put("username", userName); requestJsonObject.put("password", password); JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST, ServiceUrls.LOGIN_URL, requestJsonObject, loginResponseListener, loginErrorListener); private Listener<JSONObject> loginResponseListener = new Listener<JSONObject>() { @Override public void onResponse(JSONObject resposne) { //other stuff goes

Can't set HttpWebRequest timeout higher than 100 seconds when doing a POST?

痞子三分冷 提交于 2019-12-03 12:21:00
I am running into an issue where HttpWebRequest won't respect a timeout value higher than 100 seconds when doing a POST. However, if the request is a GET, a timeout value higher than 100 seconds is respected. The timeout exception is thrown at the .GetResponse() call. I'm setting all the timeout values I have been able to discover but it seems I am missing one, or there is a bug in the framework. This is a C# app targeting the .NET Framework 3.5, built using Visual Studio 2008. The web server is IIS 6.0 with a connection timeout set to the default 120 seconds, keep-alives enabled... again GET

how to use requests.post() with proxy authentication in python?

北慕城南 提交于 2019-12-03 10:14:57
from bs4 import BeautifulSoup import requests from requests.auth import HTTPProxyAuth url = "http://www.transtats.bts.gov/Data_Elements.aspx?Data=2" proxies = {"http":"xxx.xxx.x.xxx: port"} auth = HTTPProxyAuth("username", "password") r = requests.get(url, proxies=proxies, auth=auth) soup = BeautifulSoup(r.text,"html.parser") viewstate_element = soup.find(id = "__VIEWSTATE").attrs viewstate = viewstate_element["value"] eventvalidation_element = soup.find(id="__EVENTVALIDATION").attrs eventvalidation = eventvalidation_element["value"] data = {'AirportList':"BOS",'CarrierList':"VX",'Submit':

How to send data in the HTTP request body when using an HTML form?

孤人 提交于 2019-12-03 10:07:31
The HTTP spec says that a POST request can contain an arbitrary body of data. An HTML form element can POST to a URL and may contain input elements, but those input elements get turned into a query string. How can I get a form to also send along data in the body of the HTTP POST request that it sends when its submit button is pressed? The HTTP spec says that a POST request can contain an arbitrary body of data. That's correct. There are in turn however several specifications of the format of that data. In case of HTML forms, most commonly used is application/x-www-form-urlencoded , followed by

WCF WebInvoke Method POST

*爱你&永不变心* 提交于 2019-12-03 10:04:01
I have a wcf service, and I want to test posting data to it. But the parameter of my function never gets any values. [OperationContract] [WebInvoke(UriTemplate = "TestPost", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] int Test(string value); public int Test(string value) //Value stays null { return 0; } The JSON request I send, build using Fiddler2 http://localhost:49633/Service1.svc/TestPost User-Agent: Fiddler Host: localhost:49633 Content-Length: 42 Content-type: application/json {"value":{

How to parse json of an incoming POST request in Rails?

若如初见. 提交于 2019-12-03 09:52:11
I have the following problem. A web service is sending a JSON POST request to my app and I want to parse it. I thought I just can access the params with @var = params[:name_of_the_JSON_fields] but it doesn't work. I see in my Heroku logs, that the request is done and that the parameters are there, but I just can't store them. Does anyone have an idea? When you post JSON (or XML), rails will handle all of the parsing for you, but you need to include the correct headers. Have your app include: Content-type: application/json And all will be cool. This answer may not be particular to this exact

Fiddler not capturing HTTP requests from Java Application

不羁岁月 提交于 2019-12-03 09:37:06
I am currently writing a java application that uses HTTP POST to upload a csv file and a few other parameters to a server. The server keeps returning 500 errors to my application and I would like to view the HTTP request in Fiddler so I can see the POST request. When I run Fiddler it will not capture any HTTP traffic from the Java application. I have written a GET request that works, so I know I can communicate with the server, however no traffic is shown through Fiddler. Robert You can simply set Fiddler as HTTP proxy for your application by setting the properties http.proxyHost to localhost

How to make OKHTTP post request without a request body?

浪子不回头ぞ 提交于 2019-12-03 09:33:15
Possible way to make OkHTTP post request without a request body in okhttp library ? Justcurious RequestBody reqbody = RequestBody.create(null, new byte[0]); Request.Builder formBody = new Request.Builder().url(url).method("POST",reqbody).header("Content-Length", "0"); clientOk.newCall(formBody.build()).enqueue(OkHttpCallBack()); This worked for me: RequestBody body = RequestBody.create(null, new byte[]{}); 来源: https://stackoverflow.com/questions/35743516/how-to-make-okhttp-post-request-without-a-request-body

Simple HTTP POST in Windows Phone 8

十年热恋 提交于 2019-12-03 09:02:00
I have a string that I need to POST in Windows Phone 8. It looks like this: https://www.scoreoid.com/api/getPlayers?api_key=[apiKey]&game_id=[gameID]&response=xml&username=[username]&password=[password] This string simply returns another string (that is formatted as XML that I parse later in my code). I have yet to find a simple solution to this like in Windows 8. Edit: Found the solution to my problem with an assist from rciovati and the HttpClient library. Here's my simple code: var httpClient = new HttpClient(); return await httpClient.GetStringAsync(uri + "?" + post_data); Using the new