Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 8

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

0 Kudos
5 Replies

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)

- Marc Netterfield, Github

@mesverrum I am getting same error for the Log Parser template..

Can you assist me?

This is the thread i have opened.


0 Kudos

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) )


0 Kudos

I'd try taking the $user and $pass variables and make the script print them out in one of the messages to make sure they don't have any kind of typo or something

- Marc Netterfield, Github

i managed to figure out the problem -

i had to put commas

username = '${USER}'

the documentation is terrible