Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why is the difference between the code generated in postman and by httpsnippet? #315

Open
AmrinderS21 opened this issue Feb 20, 2023 · 1 comment

Comments

@AmrinderS21
Copy link

AmrinderS21 commented Feb 20, 2023

I was trying to use httpSnippet to generate client-code in C# and I got

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);

which is differed from I got in 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);

are they same ?
why is the differnece ?

@UVLabs
Copy link

UVLabs commented Mar 2, 2023

Sidenote: You should probably edit your issue to remove your access token from the code snippets you shared aboves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants