QTP - How to add a new folder to the QC Resource Module Using OTA

QTP – How to add a new folder to the QC Resource Module Using OTA

Code Hacker

The question of the week comes from Venky who writes:

“Thanks for the excellent post. In addition, How would I add a ‘Resource Folder’ through API? Can you please help how to create resource folder throught API?

OTA Code to add a folder

Thanks for the question! This is how I would use OTA to add a folder to the Resource module:

Set qcConn = QCUtil.QCConnection
Set resRoot = qcConn.QCResourceFolderFactory.Root
Set newFolder = resRoot.QCResourceFolderFactory.AddItem(null)
newFolder.ParentId = resRoot.ID
newFolder.Name = ”

So what is happening here with OTA?

If you don’t have it already you should download the QC OTA_API_Reference.chm help file. This file contains information on all the valid object methods and properties for Open Test Architecture Reference (OTA) API.

QCConnection object

You need to first return Quality Center’s OTA QCConnection object. This object allows you to get the current QC session and provides access to the QC object model from QTP.

Set qcConn = QCUtil.QCConnection

QCResourceFolderFactory Object

Then you need to get the Root property of the QCResourceFolderFactory Object. The QCResourceFolderFactory manages the QC resource folders and it’s Root property returns the root resource folder labeled ‘Resources’

Set resRoot = qcConn.QCResourceFolderFactory.Root

Next we need to use the QCResourceFolderFactory’s AddItem method to create a new item object passing it a null value. Passing NULL as the argument creates a virtual object, one that does not appear in the project database. After creating the item, use the relevant object properties to fill the object, then use the Post method to save the object in the database. This is the recommended technique for creating most objects that will be saved in the database.

Post it!

Last pass the new folder name and post the change to QC:

newFolder.ParentId = resRoot.ID
newFolder.Name = “TestJoeDEMOAddResourceFolder”

New Resource Folder Created!

You should now have a new folder under the Resource folder in the Quality Center Test Resources module.

Ravi - May 29, 2012

How to add a new resource of type “Test Resource” under a folder in the Resources Module of ALM/QC using VB Script.

    Joe Colantonio - May 29, 2012

    Ravi » Hi Ravi – check put my post: VIDEO – How to save a file to a QC resource using QTP with OTAVIDEO – How to save a file to a QC resource using QTP with OTA

      Ravi - June 1, 2012

      I’ve seen that Joe. Here, I want to know how to create that Test Resource itself. I.e., I need to create a new test resource under a folder, to which we can upload any file as your video says.

      Please share your knowledge..Thanks.

        Vinothkumar Manoor Chinnasamay - March 8, 2013

        Need infor for the same

Udayakiran - June 5, 2012

Thanks for the info on OTA.In my Project I am working on one requirement where I need to upload and Excel file as an Attachment to ALM/QC.I have written code for that using OTA.In that I used statement Attachment.Post to save the attachment
to ALM.But at this statement QTP throwing popup message
“you are not authorized to perform this action”. The Excel file name is appearing in ALM which we uploaded but the content we placed in the Excel is not getting uploaded(filesize in ALM is 0KB).Please let me know how to overcome this?

    Joe Colantonio - June 9, 2012

    Udayakiran » Hi Uday – it sound like some sort of permission issues. What rights do you have in the QC project that you are trying to upload to? Are you able to manually perform this action without getting this error?

      Nag - April 9, 2015

      Im using ALM12.01 version, manually if i upload a file it is fine, uploaded with actual size. But if i do through OTA client, then only it is getting uploaded with size 0KB and some 1970 date. I tried with project admin credentials also. Please guide me how to resolve this issue.

Vinothkumar Manoor Chinnasamay - March 8, 2013

I want to know how to create that Test Resource under foldera as asked by Ravi in his post above

ganesh - April 9, 2013

hi Joe
we have also same problem like udayakiran said.while post the file to ALM we are getting a error message like “Simple entity error” when execute post method.
What could be the cause of error? can you pls tell us

    Joe Colantonio - April 9, 2013

    ganesh » What line of code is failing on?

ganesh - April 10, 2013

set tdc = QCUtil.QCConnection
theShortFileName = “Assegno” ‘ This is the Name of the Resource in the Test Resource folder of QC– This should the avaliable in QC
UploadFolder = “D:\Datasheet” ‘ Local System Folder
UploadFile = “Assegno_data.xls” ‘File to be uploaded
Set oResourceFactory = tdc.QCResourceFactory
Set oRoot = oResourceFactory.NewList(“”)
Set oSub = Nothing
iTotalItems = oRoot.Count
For ItemCtr = 1 To iTotalItems
CurItem = oRoot.Item(ItemCtr).Name
print CurItem
If UCase(CurItem) = UCase(theShortFileName) Then
Set oSub = oRoot.Item(ItemCtr)
msgbox “found”
Exit for
End If
oSub.Filename = UploadFile ‘ This is the file Which is der in the UploadFolder Path
oSub.ResourceType = “Data table”
oSub.UploadResource UploadFolder, True
set oRoot = Nothing
set oResourceFactory = Nothing

line of error

error message: Faild to post simple entity

Kedara - April 22, 2013

Hi Ganesh,
pls set the Parameter Parameter to ‘N’ from Site admin-> Site Configuration.

    Kedara - April 22, 2013


Raghu - May 16, 2013

Looking for scripts / tools to do a bulk upload of test cases using the check-in and similarly if scripts whcih checks-out bulk test cases. Bascially, need to use the check-in and check-out feature of qc with huge test cases. – Any suggestion.

Thirunavukkarasu - October 10, 2013

Hi Author,

How to delete a particular file placed in the QC Resource Tab.
Ex.Report folder with 3 files available in QC ->Resources .

Want to delete the 3 files from Report folder available in QC using QTP scripts.


Damu - April 22, 2014

Hi Joe,
I have a requirement with REST API, so that i need to generate few documents.
Issue is I am new to this and can i have a sample of code or any examples, so that I can make the filter up from there or any documentation on the same would be much appreciated.


Pradeep Kumar - June 3, 2014


How can i setup test lab in the ALM using OTA.

Sunny - June 20, 2014

Hi Joe,

I am trying create folder and Subfolders in ALM in Resources section.
The above code is working fine and created folder under Resources. But, I am not able to find solution to create subfolder under newly created folder.

Bastian-31 - September 15, 2017

Hello Everybody,

I need to make a code for HP UFT that is moving a Test Resource from one Folder to Other. Please Help if anybody has Suggestions. Thx

Click here to add a comment

Leave a comment: