API Examples
Create Smart Boundary APS Job
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const TOKEN = 'YOUR_TOKEN'
const JOB_ID = '2024_08_27_18000'
const PARTY_ID = '53b8f2b9-0000-0000-0000-9c821feb0ee2'
const FARM_ID = "4b879eea-0000-0000-0000-cb608529c0f8"
const endpoint = `${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:create?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
const data = {
"requestPath": `/v1/smart-boundary/${JOB_ID}`,
"partnerRequestBody": {
"imageEndDate": "2023-08-21",
"imageStartDate": "2023-08-08",
"partyId": PARTY_ID,
"pointOnSurface": {
"longitude": -92.9819,
"latitude": 41.5046
},
"resourceId": FARM_ID,
"resourceType": "Farm"
}
}
axios.post(endpoint, data, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
TOKEN = "YOUR_TOKEN"
JOB_ID = "YOUR_JOB_ID"
PARTY_ID = "YOUR_PARTY_ID"
FARM_ID = "YOUR_FARM_ID"
endpoint = "{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:create?api-version={ADMA_API_VERSION}".format(
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL, ADMA_API_VERSION=ADMA_API_VERSION
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
data = {
"requestPath": "/v1/smart-boundary/{JOB_ID}".format(JOB_ID=JOB_ID),
"partnerRequestBody": {
"imageEndDate": "2023-08-21",
"imageStartDate": "2023-08-08",
"partyId": PARTY_ID,
"pointOnSurface": {
"longitude": -92.9819,
"latitude": 41.5046
},
"resourceId": FARM_ID,
"resourceType": "Farm",
},
}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
curl --location \
--request POST "${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:create?api-version=${ADMA_API_VERSION}" \
--header "Authorization: Bearer ${TOKEN}" \
--header 'Content-Type: application/json' \
--data-raw "{
\"requestPath\": \"/v1/smart-boundary/${JOB_ID}\",
\"partnerRequestBody\": {
\"imageEndDate\": \"2023-08-21\",
\"imageStartDate\": \"2023-08-08\",
\"partyId\": \"${PARTY_ID}\",
\"pointOnSurface\": {
\"longitude\": -92.9819,
\"latitude\": 41.5046
},
\"resourceId\": \"${FARM_ID}\",
\"resourceType\": \"Farm\"
}
}"
Create Job Response Sample
{
"e2eId": "d4fe42883d7c8bbc511754eb7940ae64",
"id": "20240903_094300",
"jobCreatedDateTime": "2024-09-03T17:12:37Z",
"jobLastActionDateTime": "2024-09-03T17:12:37Z",
"message": "MESA-01001: Job queued successfully.",
"partnerRequestBody": {
"modelSpec": {
"imageEndDate": "2023-08-21",
"imageStartDate": "2023-08-08",
"pointOnSurface": {
"longitude": -92.9819,
"latitude": 41.5046
}
},
"partyId": "53b8f2b9-0000-0000-0000-9c821feb0ee2",
"resourceId": "4b879eea-0000-0000-0000-cb608529c0f8",
"resourceType": "Farm"
},
"status": "WAITING"
}
Fetch Smart Boundary APS Job Status
This will provide the status of the running job. Possible status values are: WAITING
, RUNNING
, SUCCEEDED
,
FAILED
, CANCELLED
.
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const TOKEN = 'YOUR_TOKEN'
const JOB_ID = '2024_08_27_18000'
const endpoint = `${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:fetch?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
const data = {
"requestPath": `/v1/smart-boundary/${JOB_ID}`
}
axios.post(endpoint, data, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
TOKEN = "YOUR_TOKEN"
JOB_ID = "2024_08_27_18000"
endpoint = "{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:fetch?api-version={ADMA_API_VERSION}".format(
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL, ADMA_API_VERSION=ADMA_API_VERSION
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
data = {"requestPath": "/v1/smart-boundary/{JOB_ID}".format(JOB_ID=JOB_ID)}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
curl --location \
--request POST "${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:fetch?api-version=${ADMA_API_VERSION}" \
--header "Authorization: Bearer ${TOKEN}" \
--header 'Content-Type: application/json' \
--data-raw "{\"requestPath\":\"/v1/smart-boundary/${JOB_ID}\"}"
Fetch Job Status Response Sample
{
"e2eId": "bd04d347c00000000000000a444b8cea",
"id": "2024_08_27_18000",
"insightId": "468799eb-0000-0000-0000-aab05869701f",
"jobCreatedDateTime": "2024-08-27T18:18:41Z",
"jobLastActionDateTime": "2024-08-27T18:19:11Z",
"jobProcessingDurationInSeconds": 28,
"jobProcessingEndDateTime": "2024-08-27T18:19:11Z",
"jobProcessingStartDateTime": "2024-08-27T18:18:43Z",
"message": "Job is completed successfully.",
"partnerRequestBody": {
"imageEndDate": "2023-08-21",
"imageStartDate": "2023-08-08",
"partyId": "53b8f2b9-0000-0000-0000-9c821feb0ee2",
"pointOnSurface": {
"longitude": -92.9819,
"latitude": 41.5046
},
"resourceId": "4b879eea-0000-0000-0000-cb608529c0f8",
"resourceType": "Farm"
},
"status": "SUCCEEDED"
}
Cancel Smart Boundary APS Job
Jobs can only be cancelled if they are in a cancellable state: WAITING
or RUNNING
.
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const TOKEN = 'YOUR_TOKEN'
const JOB_ID = '2024_08_27_18000'
const endpoint = `${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:cancel?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
const data = {
"requestPath": `/v1/smart-boundary/${JOB_ID}`
}
axios.post(endpoint, data, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
TOKEN = "YOUR_TOKEN"
JOB_ID = "2024_08_27_18000"
endpoint = "{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:cancel?api-version={ADMA_API_VERSION}".format(
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL, ADMA_API_VERSION=ADMA_API_VERSION
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
data = {"requestPath": "/v1/smart-boundary/{JOB_ID}".format(JOB_ID=JOB_ID)}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
curl --location \
--request POST "${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.smartBoundary:cancel?api-version=${ADMA_API_VERSION}" \
--header "Authorization: Bearer ${TOKEN}" \
--header 'Content-Type: application/json' \
--data-raw "{\"requestPath\":\"/v1/smart-boundary/${JOB_ID}\"}"
Cancel Job Response Sample
{
"e2eId": "752c31c255591717c7d844708e310b4b",
"id": "2024_08_27_18000",
"jobCreatedDateTime": "2024-09-03T17:27:11Z",
"jobLastActionDateTime": "2024-09-03T17:51:09Z",
"message": "Job is cancelled successfully.",
"partnerRequestBody": {
"modelSpec": {
"imageEndDate": "2023-08-21",
"imageStartDate": "2023-08-08",
"pointOnSurface": {
"longitude": -92.9819,
"latitude": 41.5046
}
},
"partyId": "53b8f2b9-0000-0000-0000-9c821feb0ee2",
"resourceId": "4b879eea-0000-0000-0000-cb608529c0f8",
"resourceType": "Farm"
},
"status": "CANCELLED"
}
Insight Attachments API: Get Outputs
The Smart Boundary Service writes the predicted activity boundary in GeoJSON format as an insight attachment stored in the ADMA instance of the caller. The ADMA Insight Attachment API describes the process. What follows is an example.
Get the list of Insight Attachments
Request Sample
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const PARTY_ID = 'YOUR_ADMA_PARTY_ID'
const FARM_ID = 'YOUR_ADMA_FARM_ID'
const TOKEN = 'YOUR_TOKEN'
const endpoint = `${ADMA_INSTANCE_URL}/parties/${PARTY_ID}/models/bayerAgPowered.
smartBoundary/resource-types/Farm/resources/${FARM_ID}/insight-attachments?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
axios.get(endpoint, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
PARTY_ID = 'YOUR_ADMA_PARTY_ID'
FARM_ID = 'YOUR_ADMA_FARM_ID'
TOKEN = 'YOUR_TOKEN'
endpoint = "{ADMA_INSTANCE_URL}/parties/{PARTY_ID}/models/bayerAgPowered.smartBoundary/resource-types/Farm/resources/{FARM_ID}/insight-attachments?api-version={ADMA_API_VERSION}".format(
PARTY_ID=PARTY_ID,
FARM_ID=FARM_ID,
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL,
ADMA_API_VERSION=ADMA_API_VERSION,
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
response = requests.get(endpoint, headers=headers)
print(response.json())
curl --location \
--request GET "${ADMA_INSTANCE_URL}/parties/${PARTY_ID}/models/bayerAgPowered.smartBoundary/resource-types/Farm/resources/${FARM_ID}/insight-attachments?api-version=${ADMA_API_VERSION}" \
--header "Authorization: Bearer ${TOKEN}" \
--header 'Content-Type: application/json'
The PARTY_ID
and FARM_ID
parameters are the same as the ones used when requesting the image in the PUT request.
Response Sample
If you call the solutions API for bayerAgPowered.smartBoundary multiple times with the same Farm ID, you will get multiple attachment IDs in this list.
{
"value": [
{
"createdBy": "598abd48-0000-0000-0000-2494c382417e",
"createdDateTime": "2024-08-27T05:46:01Z",
"eTag": "c6002677-0000-0000-0000-66cd68190000",
"id": "76463056-0000-0000-0000-14fea58bb7d9",
"insightId": "bbbbbbbb-0000-0000-2024-000826224525",
"modelId": "bayerAgPowered.smartBoundary",
"modifiedBy": "598abd48-0000-0000-0000-2494c382417e",
"modifiedDateTime": "2024-08-27T05:46:01Z",
"originalFileName": "smart_boundary.json",
"partyId": "53b8f2b9-0000-0000-0000-9c821feb0ee2",
"resourceId": "4b879eea-0000-0000-0000-cb608529c0f8",
"resourceType": "Farm"
}
]
}
Get the Smart Boundary
You can download the insight attachment (i.e., the smart boundary geoJSON) using the id
specified above (e.g., "76463056-0000-0000-0000-14fea58bb7d9"
) as follow:
Request Sample
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const PARTY_ID = 'YOUR_ADMA_PARTY_ID'
const FARM_ID = 'YOUR_ADMA_FARM_ID'
const ATTACHMENT_ID = 'YOUR_INSIGHT_ATTACHMENT_ID'
const TOKEN = 'YOUR_TOKEN'
const endpoint = `${ADMA_INSTANCE_URL}/parties/${PARTY_ID}/models/bayerAgPowered.
smartBoundary/resource-types/Farm/resources/${FARM_ID}/insight-attachments/${ATTACHMENT_ID}/file?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
axios.get(endpoint, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
PARTY_ID = 'YOUR_ADMA_PARTY_ID'
FARM_ID = 'YOUR_ADMA_FARM_ID'
ATTACHMENT_ID = 'YOUR_INSIGHT_ATTACHMENT_ID'
TOKEN = 'YOUR_TOKEN'
endpoint = "{ADMA_INSTANCE_URL}/parties/{PARTY_ID}/models/bayerAgPowered.smartBoundary/resource-types/Farm/resources/{FARM_ID}/insight-attachments/{ATTACHMENT_ID}/file?api-version={ADMA_API_VERSION}".format(
PARTY_ID=PARTY_ID,
FARM_ID=FARM_ID,
ATTACHMENT_ID=ATTACHMENT_ID,
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL,
ADMA_API_VERSION=ADMA_API_VERSION,
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
response = requests.get(endpoint, headers=headers)
print(response.json())
curl --location \
--request GET "${ADMA_INSTANCE_URL}/parties/${PARTY_ID}/models/bayerAgPowered.smartBoundary/resource-types/Farm/resources/${FARM_ID}/insight-attachments/${ATTACHMENT_ID}/file?api-version=${ADMA_API_VERSION}" \
--header "Authorization: Bearer ${TOKEN}" \
--header 'Content-Type: application/json'
Response Sample
{
"coordinates": [
[
[-93.00131777750342, 41.496716143095675], [-92.97077915983267, 41.519688251230605],
[-92.97076746028371, 41.51968767646862], [-92.97076688552173, 41.5196759769197],
[-92.97077915983267, 41.49671556833369], [-93.00131777750342, 41.496716143095675]
]
],
"type": "Polygon"
}