标签:tpc service api cells error pad arp list std
1
2
3
4
5
|
String url = "***" ; String postString = "{ \"appKey\": \"***\", \"appSecurity\": \"***\" , \"accessType\": \"2\"}" ; String result = PostData (url, postString); |
POST JSON示例:
1
|
{"appKey": "***","appSecurity": "***" ,"accessType": "2"} |
返回JSON示例:
1
2
3
4
5
6
7
8
9
10
11
|
{ "status" : { "success" : true , "errorCode" : null , "message" : null }, "data" : { "expireTime" : 7200, "accessToken" : "6b30a440a9c426e27de13f63f4170fc0" } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
String url = "***" ; // 请求链接 String sign = "9488373060c8483a3ef6333353fdc7fe" ; // sign OkHttpClient okHttpClient = new OkHttpClient(); // OkHttpClient对象 JSONObject jsonObject = new JSONObject(); JSONObject jsObject = new JSONObject(); jsObject.put( "appKey" , "******" ); jsObject.put( "accessToken" , "*****" ); // token jsonObject.put( "authInfo" , jsObject); jsonObject.put( "apiName" , "QuerySubAccountStructService" );
JSONObject contentJson = new JSONObject();
contentJson.put( "pageIndex" , 1);
jsonObject.put( "requestContent" , contentJson); RequestBody requestBody = FormBody.create(MediaType.parse( "application/json; charset=utf-8" ) , jsonObject.toJSONString()); Request request = new Request.Builder().url(url).addHeader( "sign" , sign).post(requestBody).build(); // 请求 okHttpClient.newCall(request).enqueue( new Callback() { // 回调 public void onResponse(Call call, Response response) throws IOException { System.out.println(response.body().string()); //成功后的回调 } public void onFailure(Call call, IOException e) { System.out.println(e.getMessage()); //失败后的回调 } }); |
POST JSON示例:
1
2
3
4
5
6
7
8
|
{ "authInfo":{ "appKey":"****", "accessToken":"5d4cca4b07195715b8003113" }, "requestContent":"{"accountID":1234,pageSize":50,"pageIndex":1}", "apiName":"QuerySubAccountStructService" } |
返回JSON示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
{ "data" : { "totalCount" : 2, "subAccountList" : [ { "subAccountID" : 4161, "subAccountName" : "subdebtcorp" , "status" : "A" , "userCount" : 2 }, { "subAccountID" : 6528, "subAccountName" : "test" , "status" : "A" , "userCount" : 893 } ] }, "status" : { "errorCode" : 0, "message" : "返回成功" , "success" : true } } |
标签:tpc service api cells error pad arp list std
原文地址:https://www.cnblogs.com/omar/p/12697484.html