星空云rust webapi 查询科目名称
use reqwest::header::CONTENT_TYPE;
use reqwest::{redirect::Policy};
use kd_test1::{LoginRequest,Paramskd,Data};
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = "http://192.168.0.85/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc";
let client = reqwest::Client::builder()
.redirect(Policy::limited(2))
.cookie_store(true)
.build()
.unwrap();
// 构造请求参数
let parameters = LoginRequest {
// acctID: "600979bb86e6ac".to_string(),
//6400279d8606d6
acctID: "643ce9f1372ab5".to_string(),
username: "Administrator".to_string(),
password: "k_888888".to_string(),
lcid: 2052,
};
let body = serde_json::to_string(¶meters).unwrap();
println!("用户传参:{}", &body);
let response = client
// .redirect(Policy::limited(2))
// .cookie_store(true)
.post(url)
//.text_with_charset("utf-8")
.header(CONTENT_TYPE, "application/json;charset=UTF-8")
.body(body)
.send()
.await?
.text()
.await?;
let result = serde_json::from_str::<Value>(&response)?;
let i_result = result["LoginResultType"].as_i64().unwrap_or(0);
if i_result == 1 {
println!("登录验证成功,处理业务");
}
let aata = Data::data {
CreateOrgId: 0,
Number: "1001".to_string(),
Id: "".to_string(),
IsSortBySeq: false,
};
let paramskd = Paramskd {
formid: "BD_Account".to_string(),
data: aata,
};
let ejson3 = serde_json::to_string(¶mskd).unwrap();
println!("data传参{:?}", &ejson3);
let Response2=client
.post("http://192.168.0.85/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc")
.header(CONTENT_TYPE, "application/json")
.body(ejson3)
.send()
.await?
.text()
.await?;
println!("{:#?}", Response2);
Ok(())
}
==============crate kd_test1kd_test1======
use serde::{Deserialize, Serialize};
#[derive(Serialize, Debug)]
pub struct LoginRequest {
pub username: String,
pub password: String,
pub acctID: String,
pub lcid: i32,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Paramskd {
pub formid: String,
pub data: Data,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(untagged)] //对此枚举使用未标记的枚举表示形式
pub enum Data {
data {
CreateOrgId: i32,
Number: String,
Id: String,
IsSortBySeq: bool,
},
}
异步的哟
星空云rust webapi 查询科目名称
use reqwest::header::CONTENT_TYPE;use reqwest::{redirect::Policy};use kd_test1::{LoginRequest,Paramskd,Data};use serde::{Deser...
点击下载文档
本文2024-09-16 18:31:29发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22699.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章