get

Convert JSON data to querystring in C# GET request

坚强是说给别人听的谎言 提交于 2019-12-05 15:52:32
What is the best way to convert a JSON object into querystrings to append to a GET Url? The POST is straight forward and gets read by my Web API backend. {Name: 'Mike' } = ?Name=Mike private static string MakeRequest(HttpWebRequest req, string data) { try { if (req.Method == Verbs.POST.ToString() || req.Method == Verbs.PUT.ToString() || req.Method == Verbs.DELETE.ToString()) { var encodedData = Encoding.UTF8.GetBytes(data); req.ContentLength = encodedData.Length; req.ContentType = "application/json"; req.GetRequestStream().Write(encodedData, 0, encodedData.Length); } using (var response = req

How to send a getForObject request with parameters Spring MVC

守給你的承諾、 提交于 2019-12-05 14:56:50
问题 I have a method on the Server side which gives me information about an specific name registered in my database. I'm accessing it from my Android application. The request to Server is done normally. What I'm trying to do is to pass parameter to the server depending on the name I want to get. Here's my Server side method: @RequestMapping("/android/played") public ModelAndView getName(String name) { System.out.println("Requested name: " + name); ........ } Here's the Android request to it:

Escaping PHP GET and POST values [duplicate]

别来无恙 提交于 2019-12-05 13:40:38
Possible Duplicate: The ultimate clean/secure function I was informed in another thread that this bit of code was pretty useless: function getPost($s) { if (array_key_exists($s, $_POST)) return mysql_real_escape_string(htmlspecialchars($_POST[$s])); else return false; } function getGet($s) { if (array_key_exists($s, $_GET)) return mysql_real_escape_string(htmlspecialchars($_GET[$s])); else return false; } Can anybody help understand why and how I can make it better please? Links or references are welcome also. Just trying to always improve :) Well, it's bad for the same way magic_quotes_gpc is

Spotify: Login using the web api not accepting redirect url

社会主义新天地 提交于 2019-12-05 13:38:38
I am trying to login to Spotify using the Web API since I don't need a session object. In my authorize method, I need to pass in the redirect url, but the way that the iOS redirect url is formatted is not accepted in a .GET request. func authorize() { // create the url let url = "https://accounts.spotify.com/authorize" // parameters let parameters = ["client_id" : kClientID, "response_type" : "code", "redirect_uri" : "spotify-discover-login://callback", "state" : kState, "scope" : kScopes] // response code var responseCode = 401 Alamofire.request(.GET, url, parameters: parameters, headers: nil

Send a simple GET request

被刻印的时光 ゝ 提交于 2019-12-05 13:17:56
I want to send a server simple GET request but as I see the .ajax sends x-requested-with header which my server doesn't understand. $.ajax({ type: 'GET', url: 'coord-' + x + '-' + y + '-' + iname, success: function(data) { $('img').each(function(idx, item) { var img_attr = $(this).attr("src") var name = img_attr.match(/\d+-\d+\.\w+/) name = name + '?r=' + Math.random() $(this).removeAttr("src") $(this).attr("src",name) }) }, }) in headers ---> X-Requested-With: XMLHttpRequest Is it possible to send a simple request without using x-request-with? This looks like you need to set the contentType

How can Flash scope help in implementing the PostRedirectGet (PRG) pattern in JSF2.0

本小妞迷上赌 提交于 2019-12-05 13:02:40
I was reading Balusc blog on PRG pattern in JSF where it is mentioned that : This article is targeted on JSF 1.2. For JSF 2.0, this can easier be achieved using the new Flash scope. I wanted to find out how can flash scope help us in achieving the same ? Call Flash#setKeepMessages() with true before render response phase to instruct JSF to store the faces messages in the flash scope and add faces-redirect=true query string parameter to the outcome to perform a redirect. public String submit() { // ... FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(null, new

getActivity() returns a null in my ActivityInstrumentationTestCase2 class

旧巷老猫 提交于 2019-12-05 11:29:31
I want my app to perform the following test in the code with ActivityInstrumentationTestCase2. The problem is the getActivity() method returns a null. This results in a NullPointerException at the line directly underneath the line that contains getActivity(). As a result, the test cannot run. I don't know why it is doing that. I have already tried changing @Before to @Override but the problem continues. Here is the actual Test class: package com.example.guy.smsclassprojecttest; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.SmallTest; import

Android + PHP: Sending a GET request to PHP server

南笙酒味 提交于 2019-12-05 10:42:16
问题 I'm trying to send a GET request from an Android app to a web server, so the server will store the information in a database. Here is the Android Application : public class Final extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_final); Button btnSend = (Button)findViewById(R.id.BtnSend); btnSend.setOnClickListener(new OnClickListener(){ public void onClick(View arg0){ TestReceiver(); } }); void

Angular2 observable http get conditional repeat

早过忘川 提交于 2019-12-05 10:04:14
I'm using angular2 observable pattern to make http requests. I'm trying to conditional repeat the http get: I want to execute the http get until a condition is met: http.get('url') .map(res => { // if the condition is met I should repeat the http get request }) .subscribe() Is there a way to conditional repeat the http get request? Thanks, Marco You can use expand operator. Here's an example: let request$ = http.get('url'); request$.expand(value => { return value !== 0 ? request$ : Rx.Observable.empty() }) .map(res => { //Do mapping here }) .subscribe() 来源: https://stackoverflow.com/questions

Get the first letter of each word in a SQL string [duplicate]

家住魔仙堡 提交于 2019-12-05 09:40:54
Possible Duplicate: sql to pick apart a string of a persons name and output the initials In MS-SQL Server , there is a way to get the first letter of each word in a string? For example: Name: Michael Joseph Jackson Query: SELECT name, [function] as initial FROM Customers Result: MJJ This function will shield your results against multiple sequential spaces in the source string: CREATE FUNCTION dbo.fnFirsties ( @str NVARCHAR(4000) ) RETURNS NVARCHAR(2000) AS BEGIN DECLARE @retval NVARCHAR(2000); SET @str=RTRIM(LTRIM(@str)); SET @retval=LEFT(@str,1); WHILE CHARINDEX(' ',@str,1)>0 BEGIN SET @str