Kong / Kong/httpsnippet

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

Open
#315 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
242
PR merge metrics
No merged PRs in 30d

Description

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 ?

Contributor guide

Open the contributing guide

Research direction

Start by comparing the C# output from httpsnippet with the C# code generated by Postman for the multipart request shown in the issue. Check whether both snippets send the same file field and request body, then determine whether the discrepancy is an expected library-version difference or a generator bug; done means documenting or correcting the mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, postman, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.