Skip to content

Instantly share code, notes, and snippets.

@ibuilder
Last active April 24, 2025 16:24
Show Gist options
  • Save ibuilder/a963a9d821a9ab9f6b2984ee0db68612 to your computer and use it in GitHub Desktop.
Save ibuilder/a963a9d821a9ab9f6b2984ee0db68612 to your computer and use it in GitHub Desktop.
Python API call for Oracle Textura Payment Management (TPM) REST API,
import requests
import json
# API Servers
# Production Server: https://services.texturacorp.com/ebis/api/v1/
# Test Server: https://usint1.textura.oraclecloud.com/ebis/api/v1/
# Compliance Example
# https://services.texturacorp.com/ebis/api/v1/import/compliance-requirements
# Test: https://usint1.textura.oraclecloud.com/ebis/api/v1/import/compliance-requirements
# Authentication details (replace with your actual credentials)
client_id = "your_client_id"
client_secret = "your_client_secret"
token_url = "https://your-textura-auth-endpoint/oauth/token"
api_endpoint = "https://your-textura-api-endpoint/ords/tpm/payments"
# Function to obtain OAuth 2.0 access token
def get_access_token():
try:
headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret
}
response = requests.post(token_url, headers=headers, data=data)
response.raise_for_status() # Raise an error for bad status codes
return response.json().get("access_token")
except requests.exceptions.RequestException as e:
print(f"Error obtaining access token: {e}")
return None
# Function to make API call to Textura
def call_textura_api():
access_token = get_access_token()
if not access_token:
print("Failed to authenticate.")
return
# Sample payload for creating a payment (replace with actual payload)
payload = {
"project_id": "12345",
"amount": 1000.00,
"payee": "Contractor ABC"
}
try:
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
response = requests.post(api_endpoint, headers=headers, data=json.dumps(payload))
response.raise_for_status() # Raise an error for bad status codes
# Process response
print("Response Status Code:", response.status_code)
print("Response Body:", response.json())
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
print(f"Response: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error making API call: {e}")
# Execute the API call
if __name__ == "__main__":
call_textura_api()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment