Skip to main content

API Examples

Create Smart Boundary APS Job

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 --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 --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 --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 --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"
}