Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

vutil provides a REST API to execute multipart requests. This API handles the multipart request and response as well. This API provides options to configure your multipart request and process the multipart response as well.

...

API Endpoint for executing multipart request/process response is 

POST {{vutilBaseURL}}/request

...

  • {{vutilBaseURL}} is the variable, and the value is the base URL of the vutil server.
  • and request body has the following structure

    Code Block
    languagejs
    titleRequest Body
    {
    	"method": "<STRING>",
    	"url": "<STRING>",
    	"headers": "<OBJECT>",
    	"multipart": "<ARRAY<Part>>",
    	"formData": "<FormDataObject>"
    	"requestOptions": "<RequestOptionsObject>",
    	"responseOptions": "<ResponseOptionsObject>"
    }

    here
     * method is the request method,
     * url is the request URL which will be executed,
     * headers is JSON object containing the request headers,
     * multipart is the array of part objects,
     * requestOptions is a JSON object to configure the API request and
     * responseOptions is a JSON object containing various options to process the API response part.

    And each individual part structure is as follows:

    Code Block
    titlePart
    {
    	"headers": "<OBJECT>",
    	"body": "<STRING>" || "<PartBody>"
    }

    here
     * headers is JSON object containing the part headers and
     * body can be either string or of type PartBody.

    The structure of PartBody is as follows:

    Code Block
    titlePartBody
    {
    	"filePath": "<STRING>",
    	"body": "<Array<Part>>" //Optional - for nested multipart body
    }

    here
     * filePath is the absolute file path on the machine where vutil is installed. vutil will automatically attach this file.
     * body is the array of part objects. It will be used for the nested multipart body. 
    The structure of FormDataObject is as follows:

    Code Block
    languagejs
    titleFormDataObject
    {
    	"key1": "<SimpleValue>" || "<FileObject>" || "Array<FileObject>",
    	...
    }

    here
     * key1 is the name of the form data parameter and value can be one of SimpleValue or FileObject or array of file objects.
     * SimpleValue can be any type like string, number, boolean, JSON object etc.

    The structure of FileObject is as follows:

    Code Block
    languagejs
    titleFileObject
    {
    	"filePath": "<STRING>",
    	"options": {
    		"fileName": "<STRING>",
    		"contentType": "<STRING>"
    	}
    }

    here
     * filePath is the absolute file path of the local system where the vutil server is running.
     * fileName is the name of the file, by default file name will be extracted from the filePath parameter. This is an optional parameter.
     * contentType is the content type to be sent for this part. This is an optional parameter.

    The structure of RequestOptionsObject is as follows: 

    Code Block
    languagejs
    titleRequestOptionsObject
    {
    	"preambleCRLF": "<BOOLEAN>",
    	"postambleCRLF": "<BOOLEAN>",
    	"timeout": "<NUMBER>",
    	"oauth": "<OAuth1Object>"
    }

    here 
     * preambleCRLF: append a newline/CRLF before the boundary of your multipart/form-data request.
     * postambleCRLF: append a newline/CRLF at the end of the boundary of your multipart/form-data request.
     * timeout: Integer containing the number of milliseconds to wait for a server to send response headers (and start the response body) before aborting the request.
     * oauth: Set this property only if you are using OAuth 1.0, just set the value as OAuth1Object. For other types of authorizations, please just set the Authorization property of the test case.

    The structure of OAuth1Object is as follows:

    Code Block
    languagejs
    titleOAuth1Object
    {
    	"consumer_key": "<STRING>", //consumer key
    	"consumer_secret": "<STRING>", //consumer secret
    	"token": "<STRING>", //Access token key
    	"token_secret": "<STRING>" //Access token secret
    }

    The structure of ResponseOptionsObject is as follows:

    Code Block
    languagejs
    titleResponseOptionsObject
    {
    	"parse": "<BOOLEAN>",
    	"process": "<ProcessObject>"
    }

    here
     * parse is the boolean flag, if true, the response will be parsed into parts otherwise response string will be returned directly and
     * process is a JSON object to process the part body according to the Content-Type of the part. In ProcessObject, the key is a substring of the response content type and value can be one of the following:

    1. json: if you want to parse the JSON response part as a JSON object.
    2. xml2json: if you want to convert the XML response part into a JSON object
    3. csv2json: if you want to convert the CSV response part into a JSON object
    4. xls2json: if you want to convert the .xlsx or .xls response part into JSON object
    5. base64: if you want to encode the response part as base64 encoded string
    6. blank: if you want to ignore the part response
    7. checksum: if you want to calculate the checksum of the part response
    8. string: if you want to return the part response as a string.

...