为什么 postman 和 httpsnippet 生成的代码有区别?

Why is the difference between the code generated in postman and by httpsnippet?

提问人:Amrinder Singh 提问时间:10/31/2023 最后编辑:Divyang DesaiAmrinder Singh 更新时间:10/31/2023 访问量:26

问:

我试图使用 httpSnippet 在 C# 中生成客户端代码,我得到了

var client = new RestClient("https://api.apyhub.com/extract/text/word-file");
var request = new RestRequest(Method.POST);
request.AddHeader("apy-token", "APY0kllzrWDJ1AXxg3cfjxwfAhrXaSuarykmVh2gqleNPi0LujGn4vflrsu1MC58");
request.AddHeader("Content-Type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n@\"test.docx\"\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

这与我在 Postman 中得到的不同

var options = new RestClientOptions("https://api.apyhub.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/extract/text/word-file", Method.Post);
request.AddHeader("apy-token", "APY0kllzrWDJ1AXxg3cfjxwfAhrXaSuarykmVh2gqleNPi0LujGn4vflrsu1MC58");
request.AlwaysMultipartFormData = true;
request.AddFile("file", "/path/to/file");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

主要在我的代码中使用 kong/HTTPsnippet 和 Postman 时。request.AddParameterrequest.AddFile

我想实现类似于邮递员,有人可以帮忙吗?

邮递员 代码生成

评论


答: 暂无答案