Here is an example of a working python script used to send a Terraform config file to the IriusRisk API OTM endpoint from a Linux OS:
import requests
api_endpoint = "https://yourServer.iriusrisk.com"
api_token = 'tokenValue'
api_endpointTF = "/api/v1/products/terraform"
api_endpoint2 = api_endpoint+api_endpointTF
headers = {
'api-token': (api_token)
}
files = {'tf-file': open('testingtf.tf','rb')}
data = {
'product-id': 'testingterra',
'name': 'testingterra'
}
response = requests.post(api_endpoint2, headers=headers, files=files, data=data)
print (response)
print (response.text)
And here is an example of a working python script used from a Windows OS:
import requests
api_endpoint = "https://yourServer.iriusrisk.com"
api_token = 'tokenValue'
api_endpointTerra = "/api/v1/products/terraform"
api_endpoint2 = api_endpoint+api_endpointTerra
headers = {
'api-token': (api_token)
}
files = {
'tf-file': open('C:\\Terra\\testingtf.tf','rb')
}
data = {
'product-id': 'testingterra123',
'name': "testingterra123"
}
response = requests.post(api_endpoint2, headers=headers, files=files, data=data)
print (response)
print (response.text)
A successful response should come back with something similar to this:
<Response [201]>
{"ref":"testingterra2","name":"testingterra2","revision":"1","type":"STANDARD","status":"OPEN","priority":"0","tags":null,"workflowState":"creation","udts":[],"groups":null,"users":null}
For more advanced troubleshooting you can add some tools to the script and run it again, you want to add these lines:
from requests_toolbelt.utils import dump print(dump.dump_all(response).decode("utf-8"))
The full file would look like this:
import requests
from requests_toolbelt.utils import dump
api_endpoint = "https://yourServer.iriusrisk.com"
api_token = 'tokenValue'
api_endpointTF = "/api/v1/products/terraform"
api_endpoint2 = api_endpoint+api_endpointTF
headers = {
'api-token': (api_token)
}
files = {'tf-file': open('testingtf.tf','rb')}
data = {
'product-id': 'testingterra',
'name': 'testingterra'
}
response = requests.post(api_endpoint2, headers=headers, files=files, data=data)
print (response)
print (response.text)
print(dump.dump_all(response).decode("utf-8"))
You can use this output to submit a ticket to our support team to help resolve your issue as well!
If you are using an on-prem solution of IriusRisk, you can also attach the Startleft logs to your trouble ticket:
docker logs iriusrisk-startleft
Comments
0 comments
Please sign in to leave a comment.