The Postman request:


Request configuration

a.- Headers

Standard headers, nothing to update here.


b.- Body

Values that are used for this demo (selected as Postman type RAW):

KeyValueNotes
fileReference

"{{file-reference}}"

optional reference used by the service consumer to identify the file

fileFormatCategory

"{{file-format}}"

Can be pdf,zip,xml (for the current test b.1.2.- request to delete it will by zip)
fileChecksum

"{{file-checksum}}"

mandatory checksum of the file to upload for validation purpose. Please check here to see how to generate it, then update the Postman environment


c.- Pre-request script

This script automatically generates a general reference and updates the Postman environment with it.

setting the file reference (only for testing)
// setting the fileReference

var currentTimestamp = "file_reference_created_on_" + (Math.floor(Date.now() / 1000) );

pm.environment.set('file-reference',currentTimestamp );

console.log("bearer=",pm.environment.get('access-token'))



d.- Tests script

The following script is executed after the request is sent, to evaluate the response and also to set up environment variables (if they are needed for following requests)

// following test will verify the expected response code for this request

pm.test("Status code is 201", function () {
    pm.response.to.have.status(201);
});

// this tests if the file-id is received and then updates the postman environment with it
pm.test("file-id received", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.fileId).not.eql(undefined);
    if (jsonData.fileId !== undefined) {
        console.log("file-id:"+jsonData.fileId)
        pm.environment.set("file-id", jsonData.fileId);
    }
});
// this tests if the upload URL is received and then updates the postman environment with it
pm.test("upload URL received", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.fileUploadUrl).not.eql(undefined);
    if (jsonData.fileUploadUrl !== undefined) {
        console.log("upload-url:"+jsonData.fileUploadUrl)
        pm.environment.set("upload-url", jsonData.fileUploadUrl);
    }
});



Expected response

e.- Body

We can see there the normal JSON response with the fileId and fileUploadUrl that is being provided by the system for the upload of the file we want to register in DAS


f.- Headers

Normal headers.


g.- Test results

This depends on the test we set up in the test script



  • No labels