使用RestTemplate的HTTP获取标头
如何使用Spring RestTemplate发送GET请求?其他问题已使用POST,但我需要使用GET。当我运行它时,该程序继续工作,但是似乎网络被阻塞了,因为它在AsyncTask中,当我单击该按钮后尝试运行另一个asynctask时,它们将无法工作。 我试着做 String url = "https://api.blah.com/2.0/search/cubes?w=jdfkl&whitespace=1"; MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("Bearer", accessToken); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); //copied this from somewhere else, not sure what its for HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers); HttpMessageConverter<String> stringConverter = new StringHttpMessageConverter(); FormHttpMessageConverter formConverter = new FormHttpMessageConverter(); …