The following are some basic examples of API calls.
GET method
Retrieve Work Order header details returning specific fields and not null values:
curl --location --globoff 'http://{baseURL}/JmWorkOrder/wo_no_seq=2627-1?resultColumns={"jm_work_order":["wo_no_seq","wo_desc","wo_begin_dt","wo_end_dt","phase_desc","sched_by_name"]}&nullvaluehandling=ignore' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic *************' \
--data '@'
Response:
{
"jm_work_order": [
{
"wo_no_seq": {
"wo_no_seq": "2627-1"
},
"wo_desc": "Dscription2",
"wo_begin_dt": "2023-04-21T00:00:00Z",
"wo_end_dt": "2023-04-22T00:00:00Z",
"sched_by_name": "Xytech Support"
}
]
}
POST method
Create a new Work Order with minimal fields:
curl --location 'http://{baseURL}/JmWorkOrder' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ********' \
--data '{
"jm_work_order": [
{
"wo_desc": "Match20",
"wo_begin_dt": "2023-08-22T10:00:00.000Z",
"wo_end_dt": "2023-08-22T16:00:00.000Z",
"wo_type_no": 17,
"phase_code": "Bid",
"rate_card_no": 1,
"cust_id": 19
}
]
}'
Response:
{
"message": null,
"tables": [
"jm_work_order"
],
"jm_work_order": {
"record_identifiers": [
"wo_no_seq"
],
"records": [
{
"wo_no_seq": "8250-1"
}
]
}
}
PATCH method
curl --location --request PATCH 'http://{baseURL}/JmJob/job_no=67981' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic eHl0ZWNoOnh5dGVjaHB3' \
--data '[
{
"op": "replace",
"path": "job_desc",
"value": "Hello World"
},
{
"op": "replace",
"path": "external_key",
"value": 15411
}
]'
Response: Status Code 204
PATCH Using POST Payload
There are two PATCH methods, one where you define the field and the operation, the other is to use the full POST JSON payload.
To use the PATCH with the full JSON payload, you must include the header parameter: 'Content-Type: application/json-patch+json'
Example Work Order update using PATCH and the POST payload structure:
curl --location --request PATCH 'http://{baseURL}/JmWorkOrder/wo_no_seq=8248-1' \
--header 'Content-Type: application/json-patch+json' \
--header 'Authorization: Basic **********' \
--data '{
"jm_work_order": [
{
"wo_no_seq": {
"wo_no_seq": "8248-1"
},
"wo_desc": "My New Description",
"po": "123456",
"phase_code": "Hold"
}
]
}'
Response 200 status code
{
"message": null,
"tables": []
}
Notes:
The payload must include the existing primary key as a URL parameter as well as in the body payload.
The expected response status code for a successful PATCH can be 200 or ‘204’ where no response is returned.
PATCH using List endpoints
List endpoints also support the PATCH method so that you can update multiple records using a query (see the Working with Query Parameters and Filters article for details on available query parameters). This method is the equivalent API functionality of the Grid Update feature in the UI.
Example to update multiple Work Orders using the $range query parameter:
curl --location --globoff --request PATCH 'http://{baseURL}/JmWorkOrderList?Query={"date_added":{"$range":["2022-07-26T00:00:00","2023-07-28T00:00:00"]},"wo_type_no": 40}' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '[
{
"op": "replace",
"path": "wo_reference",
"value": "Quick Service 2"
}
]'
Response Status Code 204.
As with GET, wildcards ‘%’ are supported such as:
PATCH {baseurl}__/ JmJobList?Query={"job_desc": "Sport%"}
See many other basic payload examples in the public Postman Collection.