http-get

How to map a response from http.get to a new instance of a typed object in Angular 2 [duplicate]

非 Y 不嫁゛ 提交于 2019-11-28 08:22:16
This question already has an answer here: How do I cast a JSON object to a typescript class 17 answers I'm trying to get an understanding in how to map the result from a service call to an object using http.get and Observables in Angular 2. Take a look at this Plunk In the method getPersonWithGetProperty I'm expecting to return an Observable of type PersonWithGetProperty. However! I can't access the property fullName. I guess that I would have to create a new instance of the class PersonWithGetProperty and map the response to this new object using the class constructor. But how do you do that

Array as get parameter in Struts 2

◇◆丶佛笑我妖孽 提交于 2019-11-28 07:48:14
问题 I have an action like below public class CompareAction { private Long[] pids; public Long[] getPids() { return pids; } public void setPids(Long[] pids) { this.pids = pids; } public String displayComparison() { for (Long pid : pids) { System.out.println("pid = " + pid); System.out.println(); } return "success"; } } I'm trying to send an array by typing following url in the addressbar http://localhost:8080/sm-shop/compare?pids=12,23,34 . The output I want is pid = 12 pid = 23 pid = 34 But what

PHP cURL GET request and request's body

社会主义新天地 提交于 2019-11-28 05:22:26
i'm trying using cURL for a GET request like this: function connect($id_user){ $ch = curl_init(); $headers = array( 'Accept: application/json', 'Content-Type: application/json', ); curl_setopt($ch, CURLOPT_URL, $this->service_url.'user/'.$id_user); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HEADER, 0); $body = '{}'; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_POSTFIELDS,$body); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Timeout in seconds curl_setopt($ch, CURLOPT_TIMEOUT, 30); $authToken = curl_exec($ch); return $authToken; }

HttpClient execute keeps giving ConnectTimeoutException

ぐ巨炮叔叔 提交于 2019-11-28 00:19:14
I have this very big bug in my application that I really can't seem to solve. Whenever I make a rest call via the following code: HttpGet request = new HttpGet(url + getParams()); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 5000); HttpConnectionParams.setSoTimeout(httpParameters, 10000); DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); httpClient.execute(request); I get the error in DDMS: 07-15 11:22:47.448: WARN/System.err(973): org.apache.http.conn.ConnectTimeoutException: Connect to (some ip-address) timed

How to pass complex object to ASP.NET WebApi GET from jQuery ajax call?

回眸只為那壹抹淺笑 提交于 2019-11-27 21:07:28
问题 I have the following complex object in JavaScript which contains filter options var filter={caseIdentifiter:'GFT1',userID:'2'}; which I want to pass to an ASP.NET MVC4 WebApi controller GET [HttpGet] public IEnumerable<JHS.Repository.ViewModels.CaseList> Get([FromBody]Repository.InputModels.CaseListFilter filter) { try { return Case.List(filter); } catch (Exception exc) { //Handle exception here... return null; } } using an jQuery ajax call var request = $.ajax({ url: http://mydomain.com/case

HTTP Status 405 - HTTP method GET is not supported by this URL [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-11-27 18:33:10
问题 This question already has answers here : HTTP Status 405 - HTTP method GET is not supported by this URL (2 answers) Closed 3 years ago . The code below is from a book,so it'll not be incorrect.But I don't know how to solve this below error.When delete the method doGet(),the same error! "HTTP Status 405 - HTTP method GET is not supported by this URL" import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import javax.servlet

Add HTTP basic authentication to this HTTP GET in angularjs

余生长醉 提交于 2019-11-27 18:06:53
问题 I have an existing angularjs code which makes a HTTP GET. Extracted below is some relevant code inside the controller. .controller('imptViewCtrl', ['$scope', '$http', function ($scope, $http, ) { var url = $configuration.webroot + '/impt/list?list=testlist'; $http.get(url).then(function (response) { tableData = response.data; }); }]); I would like to add HTTP basic authentication to the HTTP GET. The username is foo and the password is bar . How can this be done? 回答1: Because in basic

Authentication Error when using HttpPost with DefaultHttpClient on Android

橙三吉。 提交于 2019-11-27 17:47:09
问题 I'm running into a strange problem using HttpClient. I am using a DefaultHttpClient() with HttpPost. I was using HttpGet with 100% success but now trying to switch to HttpPost as the REST API I'm using wants POST parameters rather than GET. (Only for some API calls though so I know that the GET calls were working fine so it's not a fault of the API). Also, I tried using HttpPost on a simple php script I wrote that looks for a POST parameter 'var' and echoes it to screen, passing this

Send both POST and GET in a form

主宰稳场 提交于 2019-11-27 15:09:36
问题 I need to make a form send both POST and GET requests (due to some bugs in IE and iframes), how can you do so? The data being sent is nothing mega secure so it doesn't matter if it can be set via GET, just need to make sure it is set both ways. Thanks for the help! 回答1: Easy: Just specify the GET data in the form URL. <form method="POST" action="form.php?a=1&b=2&c=3"> however, very carefully check how the data is used in the receiving script. Don't use $_REQUEST - rather parse $_GET and $

Multiple HTTP GET parameters with the same identifier

三世轮回 提交于 2019-11-27 15:06:32
Let's say I am getting requests such as: http://www.example.com/index.php?id=123&version=3&id=234&version=4 Is it possible to extract these in a simple way inside my php code? I realize I could get the entire querystring with javascript using window.location.href and handle it manually but I'm looking for something more elegant. The requests can contain any number of version/id pairs but I can assume that the query is well-formed and have no obligation to handle invalid strings. According to this comment from the PHP manual , PHP's query string parser will drop duplicate params... so I don't