4 Replies Latest reply on Dec 27, 2018 3:03 PM by mawan

    Credentials in script


      Hi All

      i am calling a python script that uses Request to call a REST api to get status of Jira - i created Credentials in SAM -

      the user is an application user and NOT an OS user

      i user the credential variables


      username = ${USER}

      password = ${PASSWORD}


      but - when i TEST i get the following error


      ND Get Output Failed:

      Testing on target node failed with 'Down' status ('Down' might be different if script exits with a different exit code).


      QUESTION - how do i user credentials that are defined in SAM use in script for a user thats not an OS user

        • Re: Credentials in script

          Your syntax is correct to pass user/passwords.  There is nothing different in this case for OS accounts versus any other type of account.  Does your script present the expected message and statistic outputs like described in these blog post? (obviously ignore anything specific to PoSH instead of python, but generally this is one of the best guides to script based components in sam)



          The Basics of PowerShell (part 1)

          The Basics of PowerShell (part 2)

          The Basics of PowerShell (part 3)

            • Re: Credentials in script

              Thanks for the reply

              i am using - Python and following is my full script --

              I have used both options - meaning specifying the user/password and using ${USER}/${PASSWORD}

              and it fails when using variables - the script runs on a Unix server


              import urllib2

              import base64

              import json



              #username = ${USER}

              username = "XXXXXX"

              #password = ${PASSWORD}

              password = "YYYYYY"

              request = urllib2.Request("")

              base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')

              request.add_header("Authorization", "Basic %s" % base64string)

              response = urllib2.urlopen(request).read()



              data = json.loads(response)



              print("Message.Db_check: "+str(data['statuses'][0]['name']))

              Db_check = int(data['statuses'][0]['isHealthy'])

              print("Statistic.Db_check: "+str(Db_check) )



              print("Message.Conn_setting: "+str(data['statuses'][4]['name']))

              Conn_setting = int(data['statuses'][4]['isHealthy'])

              print("Statistic.Conn_setting: "+str(Conn_setting) )



              print("Message.Open_Fiels: "+str(data['statuses'][5]['name']))

              Conn_setting = int(data['statuses'][5]['isHealthy'])

              print("Statistic.Open_Files: "+str(Conn_setting) )



              print("Message.Free_Space: "+str(data['statuses'][6]['name']))

              Conn_setting = int(data['statuses'][6]['isHealthy'])

              print("Statistic.Free_Space: "+str(Conn_setting) )