Skip to main content

API Examples

Create Crop ID APS Job

curl --location \
--request POST '{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:create?api-version={ADMA_API_VERSION}' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
"requestPath": "/v1/crop-id/1234",
"partnerRequestBody": {
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}'

Create Job Response Sample


{
"id": "1234",
"message": "MSIMAGE-01001: Job queued successfully.",
"status": "WAITING",
"jobCreatedDateTime": "2023-04-28T00:00:00Z",
"jobLastActionDateTime": "2023-04-28T00:27:00Z",
"e2eid": "a1853978d9ae412ccd55923ca41891c7",
"partnerRequestBody": {
"solutionId": "bayerAgPowered.cropid",
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}

Fetch Crop ID 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.cropid:fetch?api-version=2022-11-01-preview' \
--header 'Authorization: Bearer <JWT>' \
--header 'Content-Type: application/json' \
--data-raw '{
"requestPath":"/v1/crop-id/1234"
}'

Fetch Job Status Response Sample

{
"id": "1234",
"message": "MSIMAGE-02001: Job is completed successfully",
"status": "SUCCEEDED",
"jobCreatedDateTime": "2023-04-28T00:00:00Z",
"jobProcessingStartDateTime": "2023-04-28T00:05:00Z",
"jobProcessingEndDateTime": "2023-04-28T00:27:00Z",
"jobLastActionDateTime": "2023-04-28T00:27:00Z",
"jobProcessincropidrationInSeconds": 22,
"e2eid": "a1853978d9ae412ccd55923ca41891c7",
"partnerRequestBody": {
"solutionId": "bayerAgPowered.cropid",
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}

Cancel Crop ID 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.cropid:cancel?api-version=
{ADMA_API_VERSION}' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
"requestPath":"/v1/crop-id/1234"
}'

Cancel Job Response Sample

{
"id": "1234",
"message": "MSIMAGE-02002: Job is cancelled successfully.",
"status": "CANCELLED",
"jobCreatedDateTime": "2023-04-28T00:00:00Z",
"jobLastActionDateTime": "2023-04-28T00:27:00Z",
"jobProcessingStartDateTime": "2023-04-28T00:05:00Z",
"jobProcessingEndDateTime": "2023-04-28T00:27:00Z",
"jobProcessingDurationInSeconds": 22,
"e2eid": "a1853978d9ae412ccd55923ca41891c7",
"partnerRequestBody": {
"solutionId": "bayerAgPowered.cropid",
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}

Get Crop ID APS Output

The Crop ID APS produces a single value of the calculated Crop ID stored in a JSON output. This JSON can be accessed via the ADMA Insights API.

Insights API Request Sample

curl --location \
--request GET '{ADMA_INSTANCE_URL}/parties/{PARTY_ID}/models/bayerAgPowered.cropid/resource-types/Field/resources/{FIELD_ID}/insights/{CROPID_JOB_ID}/?api-version={ADMA_API_VERSION}'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer {TOKEN}'

Response Sample

{
"calculated_representative_point": {
"lat": 41.64569965438514,
"lon": -93.92756291287111
},
"cropid_errors": [],
"cropid_summary": [
{
"area_hectares": 23.311475,
"crop_name": "soybeans",
"crop_confidence": {
"grass": 0.0044,
"other": 0.0133,
"soybeans": 0.9823
},
"crop_year": 2022,
"iou": 0.931829
}, {
"area_hectares": 23.027851,
"crop_name": "maize",
"crop_confidence": {
"grass": 0.0044,
"maize": 0.9823,
"other": 0.0133
},
"crop_year": 2023,
"iou": 0.935912
}
],
"partner_request_body": {
"model_spec": {
"endYear": 2023,
"startYear": 2022
},
"resource_id": "90c9ffec-1111-4bfc-8a52-39dacd61756c",
"resource_type": "Field"
}
}