You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
Java
40 lines
1.0 KiB
Java
3 years ago
|
package com.customization.sendtodo;
|
||
|
|
||
|
import okhttp3.*;
|
||
|
import weaver.general.BaseBean;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class HttpReqUtils extends BaseBean{
|
||
|
|
||
|
/***
|
||
|
*
|
||
|
* @param dataJson
|
||
|
* @return
|
||
|
*/
|
||
|
public String doPostByAuth2(String dataJson){
|
||
|
BaseBean bb = new BaseBean();
|
||
|
String msgData = "" ;
|
||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||
|
.build();
|
||
|
MediaType mediaType = MediaType.parse("application/json");
|
||
|
RequestBody body = RequestBody.create(mediaType, dataJson);
|
||
|
Request request = new Request.Builder()
|
||
|
.url("http://172.16.25.133/portal-web/centerTodo/sync")
|
||
|
.method("POST", body)
|
||
|
.addHeader("Authorization", "Basic YWRtaW46VXBvcnRhbF8xMjM=")
|
||
|
.addHeader("Content-Type", "application/json")
|
||
|
.build();
|
||
|
try {
|
||
|
Response response = client.newCall(request).execute();
|
||
|
bb.writeLog("response.code():"+response.code());
|
||
|
bb.writeLog("response.body():"+response.body().string());
|
||
|
|
||
|
msgData = response.body().string();
|
||
|
} catch (IOException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
return msgData;
|
||
|
}
|
||
|
|
||
|
}
|