我有一个 JSON 数据,我需要在 POST 方法中传递它。我不知道如何将 JSON 数据转换为查询参数。请帮助我如何使用 deluge 在 POST 方法中发送这种类型的 JSON 数据。
jsonData = {
"author": "urn:li:person:12345",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Hello World! This is my first Share on LinkedIn!"
},
"shareMediaCategory": "NONE"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
这是我实际尝试过的:
headerData = Map();
headerData.put("Content-Type","application/json charset=utf-8");
headerData.put("X-Restli-Protocol-Version","2.0.0");
headerData.put("x-li-format","json");
//json data
fields = "{\"author\":\"urn:li:person:368964147\",\"lifecycleState\":\"PUBLISHED\",\"specificContent\": {\"com.linkedin.ugc.ShareContent\":{\"shareCommentary\":{\"text\": \"Hello World! This is my first Share on LinkedIn!\"},\"shareMediaCategory\": \"NONE\"}},\"visibility\":{\"com.linkedin.ugc.MemberNetworkVisibility\":\"PUBLIC\"}}";
//info fields;
response = invokeurl
[
url :"https://api.linkedin.com/v2/ugcPosts"
type :POST
parameters:fields
headers:headerData
connection:"li"
];
info response;
我预计:
参数 = 地图();
params.put("作者","urn:li:person:12345");
params.put("lifecycleState","PUBLISHED");
...很快
谢谢。