Converts Postman-SDK Request into code snippet for Csharp-RestSharp.
To run Code-Gen, ensure that you have NodeJS >= v6. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager.
The module will expose an object which will have property convert
which is the function for converting the Postman-SDK request to Csharp-RestSharp code snippet.
Convert function will take three parameters
-
request
- Postman-SDK Request object -
options
- options is an object which can have following propertiesindentType
- string representing type of indentation for code snippet. eg: 'space', 'tab'indentCount
- positiveInteger representing count of indentation required.includeBoilerplate
- Boolean denoting whether to include class definition and import statements in code snippetrequestTimeout
: Integer denoting time after which the request will bail out in milli-secondstrimRequestBody
: Boolean denoting whether to trim request body fieldsfollowRedirect
: Boolean denoting whether to redirect a request
-
callback
- callback function with first parameter as error and second parameter as string for code snippet
var request = new sdk.Request('www.google.com'), //using postman sdk to create request
options = {
indentType: 'space',
indentCount: 2,
includeBoilerplate: false
};
convert(request, options, function(error, snippet) {
if (error) {
// handle error
}
// handle snippet
});
-
Generated snippet requires dependecies mono-complete to compile and run
-
Since Postman-SDK Request object doesn't provide complete path of the file, it needs to be manually inserted in case of uploading a file.
-
content-type
needs to be specified in order to add body to the request. So if nocontent-type
is specified thentext/plain
will be used as default. In case ofmultipart/formdata
content-type
is generated by snippet itself. -
This module doesn't support cookies.