Используя RestSharp 112.1.0 и Request.AddJsonBody, как изменить имя со стандартного «application/json» на конкретное имя ?
Я постоянно получаю name="application/json"
Мой код ->
Код: Выделить всё
PackageAddDocuments.documentProperties oPackageDocuments =
new PackageAddDocuments.documentProperties();
oPackageDocuments.executionType = "E-Sign";
oPackageDocuments.name = "test1";
oPackageDocuments.order = 1;
oPackageDocuments.participants = new List
();
oPackageDocuments.participants.Add(new PackageAddDocuments.Participant()
{
participantUid = pParticipantId,
state = "REQUIRED"
});
var myPackageDocuments = Newtonsoft.Json.JsonConvert.SerializeObject(oPackageDocuments);
var myAddDocumentClient = new RestClient(options);
myAddDocumentClient.AddDefaultHeader("Authorization", accessTokenBearer);
RestRequest myAddDocumentRequest = new RestRequest(myAddDocuments, Method.Post);
myAddDocumentRequest.RequestFormat = DataFormat.Json;
myAddDocumentRequest.AlwaysMultipartFormData = true;
myAddDocumentRequest.AddJsonBody(myPackageDocuments, ContentType.Json);
myAddDocumentRequest.AddFile("contents", fullFilenameAndPath, "application/pdf");
RestResponse myRestResponse = myAddDocumentClient.Execute(myAddDocumentRequest);
Код: Выделить всё
--ddfaa976-b6fc-4521-bbe0-dd73e5f83517
Content-Type: application/json; charset=utf-8
Content-Disposition: form-data; name="application/json"
{"executionType":"E-Sign","name":"test1","order":1,"participants":[{"participantUid":"abcdefg","state":"REQUIRED"}]}
--ddfaa976-b6fc-4521-bbe0-dd73e5f83517--
Код: Выделить всё
62
{"title":"Bad Request","status":400,"detail":"Required part 'documentProperties' is not present."}
0
Информация API -> Добавить документы POST:
Код: Выделить всё
Path: POST{{Environment}}api/v2/esign/organizations/{{OrganizationID}}/packages/{{PackageID}}/executable-documents
The Post Add Documents API call adds documents to the associated package.
Required parameters:
Parameters Description
documentProperties See JSON spec below.
Contents PDF document adding to the package for signing.
Sample JSON spec for documentProperties:
{
"executionType": "Paper",
"name": "Test1",
"order": 1,
"participants": [
{
"participantUid": "{{participant ID}}",
"state": "REQUIRED"
}
]
}
Response:
201 Created
Код: Выделить всё
public class documentProperties
{
// [RequestProperty(Name = "documentProperties")]
public string executionType { get; set; }
public string name { get; set; }
public int order { get; set; }
public List
participants { get; set; }
}
public class Participant
{
public string participantUid { get; set; }
public string state { get; set; }
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ify-a-name
Мобильная версия