package jp.co.kentaku.kikan.app.f.fy.fye200.dpfye20001;
import net.sf.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
public class Talk2 {
public static String testApiRequest(MultiValueMap<String, Object> requestParams2) {
RestTemplate restTemplate = new RestTemplate();
String url = “http://api.staging.miop.pub/sys-web/rest/unauth/login”;
Map<String,Object> map= new HashMap();
map.put("account", "1");
map.put("captcha", "1");
map.put("password", "1");
map.put("rememberMe", false);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
JSONObject jsonObject = JSONObject.fromObject(map);
HttpEntity<String> request1 = new HttpEntity<String>(jsonObject.toString(), headers);
String result2 = restTemplate.postForObject(url, request1, String.class);
return result2;
}
//测试是否有效
public static void main(String[] args) {
testApiRequest(null);
}
}