Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Highlighted
Prateek Daksh Frequent Contributor.
Frequent Contributor.
293 views

want to get ALM defect data using rest api with the help of automated script.

Hi All,

I wanted to automate a script which brings the alm defect data , and save it to my location and in excel , i have created a javascript program which call the rest api but i am getting CORS error i am doing it on notepad directly and could you please help me which is the convenient way to automate to get data.

i dont have much resources like framework , that why i am doing it in notepad++.

i am using ALM 12.21 .

Thanks in advance .

0 Likes
10 Replies
Respected Contributor.. Trimper Respected Contributor..
Respected Contributor..

Re: want to get ALM defect data using rest api with the help of automated script.

As far as I know JS will only work if your JS runs from your ALM server itself.

Without some toolset or rest/api scripting capabilities, I'm not sure how you can achieve this.
0 Likes
Prateek Daksh Frequent Contributor.
Frequent Contributor.

Re: want to get ALM defect data using rest api with the help of automated script.

Thanks Trimper,

Could you please let me know , which would be the best way to achieve this , can it be work in vb script ? if i write the code in vbscript ?
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: want to get ALM defect data using rest api with the help of automated script.

Perhaps this thread could help you get started.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
0 Likes
Prateek Daksh Frequent Contributor.
Frequent Contributor.

Re: want to get ALM defect data using rest api with the help of automated script.

Thanks Jan for your reply.

i have tried your code with my values but i am getting below error , could you please help .
Appreciate your response .

Type Mismatch 'Base64Encode'


Below script i am using
Set Server = CreateObject("MSXML2.ServerXMLHttp")
username = InputBox ("User name:")
password = InputBox ("Password:")
Server.Open "GET", "myurl/qcbin/authentication/sign-in", False
Server.SetRequestHeader "Authorization", "Basic " & Base64Encode(username & ":" & password)
Server.Send

Server.SetRequestHeader "Cookie", "LWSSO_COOKIE_KEY={cookie}; Path=/"
Server.Send

Set lst = Server.responseXML.getElementsByTagName("Field")
For Each elem in lst
msgbox elem.text
Next
0 Likes
Respected Contributor.. Trimper Respected Contributor..
Respected Contributor..

Re: want to get ALM defect data using rest api with the help of automated script.

Base64Encode is typically part of a separate library, you may need to refer to your development language for the proper library.
(For quick cheat and temporary, you can just do the encoding outside and plug the string in to try out your script)
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: want to get ALM defect data using rest api with the help of automated script.

The Base64Encode that I used, borrowed from the web:

Function Base64Encode(inData)
  'rfc1521
  '2001 Antonin Foller, Motobit Software, <a href="http://Motobit.cz" target="_blank">http://Motobit.cz</a>
  Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  Dim cOut, sOut, I

  'For each group of 3 bytes
  For I = 1 To Len(inData) Step 3
    Dim nGroup, pOut, sGroup

    'Create one long from this 3 bytes.
    nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _
      &H100 * MyASC(Mid(inData, I + 1, 1)) + MyASC(Mid(inData, I + 2, 1))

    'Oct splits the long To 8 groups with 3 bits
    nGroup = Oct(nGroup)

    'Add leading zeros
    nGroup = String(8 - Len(nGroup), "0") & nGroup

    'Convert To base64
    pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _
      Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _
      Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _
      Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)

    'Add the part To OutPut string
    sOut = sOut + pOut

    'Add a new line For Each 76 chars In dest (76*3/4 = 57)
    'If (I + 2) Mod 57 = 0 Then sOut = sOut + vbCrLf
  Next
  Select Case Len(inData) Mod 3
    Case 1: '8 bit final
      sOut = Left(sOut, Len(sOut) - 2) + "=="
    Case 2: '16 bit final
      sOut = Left(sOut, Len(sOut) - 1) + "="
  End Select
  Base64Encode = sOut
End Function

Function MyASC(OneChar)
  If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)
End Function

 

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
0 Likes
Prateek Daksh Frequent Contributor.
Frequent Contributor.

Re: want to get ALM defect data using rest api with the help of automated script.

Hi All,

Thanks for you quick help in my issue , i would like to know i thought , there is something i am missing it, do i need to add any OTA client and other things with connecting ALM in case of rest api ?
or ii can directly automate it while calling it directly ?

appreciate your response .
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: want to get ALM defect data using rest api with the help of automated script.

The REST API does not require any installation, and is not dependent on the OTA, which is a separate API.

But you need to handle the session cookies.
Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
0 Likes
Prateek Daksh Frequent Contributor.
Frequent Contributor.

Re: want to get ALM defect data using rest api with the help of automated script.

Hi All,

 

Thanks , everyone for your reply now i have got the the approval to perform the same , could you please help me which framework would be the best approach to perform this task .

i am thinking about the node.js for same. 

 

appreciating your response.

 

Thanks,

Prateek Daksh 

0 Likes
Contributor.. andreipaun1 Contributor..
Contributor..

Re: want to get ALM defect data using rest api with the help of automated script.

Did you tried to use https://marketplace.microfocus.com/appdelivery/content/business-views-microsoft-excel-add ? It is linked to excel and can export all the informations you need without developing new scripts

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.