NutzCN Logo
问答 求助!!请问如何发送get带参数的请求??
发布于 1468天前 作者 ThxYouForComing 1425 次浏览 复制 上一个帖子 下一个帖子
标签:
//设置一下时间戳
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
		//给时间戳赋值
    	timestamp = df2.format(new Date());
    	seqNo = "4635768786756";
    	transNo = "234567845678";
    	businessType = "HOTEL";
    	
    	//调用UUIDUtils获取一个reqId
    	String reqString = UUIDUtils.creatUUID();
    	//这个Map是存的URL参数,请求头Header(sign除外)
    	Map<String, Object> params = new HashMap<String, Object>();
    	params.put("requestId", "WAC");
    	params.put("targetId", "MMS");
    	params.put("serviceId", "QueryStoreList");
    	params.put("timestamp", "2020-12-14 17:27:04");
    	params.put("seqNo", seqNo);
    	params.put("transNo", transNo);
    	params.put("businessType", businessType);
    	//这个是调用签名方法 然后用code接收一下签名串
    	String code = SignUtil.signToRequestGet(params,"BE266D8CC0","5924e0cfeb5b4214b4e448613e55bcf3");
    	//获取拼接参数的长度
    	int admin = SignUtil.signToRequestmap(params).length();
    	//用SubString取一下除了第一位剩下的数据
    	String pinjie = SignUtil.signToRequestmap(params).substring(1, admin);
    	System.err.println(pinjie);
    	//创建请求头
    	Header header = Header.create();
		header.set("x-dtyunxi-instanceId", "1260634217255523340");
		header.set("x-dtyunxi-reqId", "5924e0cfeb5b4214b4e448613e55bcf3");
		header.set("x-dtyunxi-sign", code);
		//发送Http请求 用response接收返回的数据
		String response = Sender.create(Request.create("http://183.63.76.163:9880/operation-service/v1/operation/item/queryStoreList", METHOD.GET, params, header))
                .setTimeout(10 * 1000)
                .send()
                .getContent();
    	return response

这是我写的请求方法,但是返回的时候给我返回的是

<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you are seeing this as a fallback.</p><div id='created'>Tue Dec 15 15:02:52 CST 2020</div><div>[e59586f5] There was an unexpected error (type=Internal Server Error, status=500).</div><div>value</div></body></html>

这是什么情况呀

2 回复

@Wizzercn 直接在URL中拼接上吗?Sender的时候还需要提交这个参数吗?

添加回复
请先登陆
回到顶部