You are not logged in.
Pages: 1
Below is an example script in python on how to consume the XLayerAPI v3.3+
import requests
from requests.structures import CaseInsensitiveDict
print("\n")
print("About to send REST Package")
print("==========================")
print()
url = "https://10.0.0.1:9788/xlayer-api/rest/async"
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
headers["Authorization"] = "Basic c3hpX2NsaWVudDpQYXNzQDEyMw=="
data = """
{
"integrationName": "FromPI-50",
"actionName": "PI50-Python",
"sourceId": "INC54321",
"payload": {
"test": "test string",
"id": 12345
}
}
"""
resp = requests.post(url, headers=headers, data=data, verify=False)
print(resp.status_code)
print(resp.text)
NOTES:
Remember to replace the 10.0.0.1 ip with the XLayer servers IP
verify=False - has been used as I was testing with a self-signed certificate
The authorization header in this example is based on Basic Authentication, however you can replace this with the appropriate JWT header
Be careful with the data field as this must be valid JSON. IF your data string is not well formed you can expect an error along the lines of: {"timestamp":"2021-05-26T12:44:24.148+00:00","status":400,"error":"Bad Request","message":"","path":"/xlayer-api/rest/async"}
Offline
Pages: 1