Troubleshooting Sjerlok Case API

Sjerlok Case API FAQ

Testing, Use cases, and Examples

In order to manually test the API, you can make use of the Postman application or directly the CLI with the cURL command.

 
1curl 2-X POST 3--header "Authorization:Token <token>" 4--header "Content-Type: application/json" 5--data '<data in JSON format>' 6https://<sjerlok-server>/api/case/vehicles/

In order to successfully execute the command, you must replace the tags with relevant data as follows:

  • <token>: This is the authorization token in order to authenticate the user making the request.

  • <data in JSON format>: the actual data for the case containing the fields described above in the Description of request body data section. More examples on how the data structure looks like can be found below with the use cases

  • <sjerlok-server>: This is the target Sjerlok application. It can be the production environment admin.sjerlok.com , the acceptance acc.sjerlok.com, or even the local environment

Successfully creating a case with all the necessary fields provided.

Payload example:

 
1{ 2 "case_number": "12345", 3 "category": "cars", 4 "disappear_date": "2017-07-05", 5 "disappear_zip_code": "123", 6 "disappear_country": "Romania", 7 "disappear_city": "Bucharest", 8 "theft_report_number": "123", 9 "case_note": "Lost object!", 10 "object_owner": { 11 "phone_number": "+31612341234", 12 "email": "owner.email@emailhost.com", 13 "name": "Owner Name" 14 }, 15 "object_data": { 16 "vin": "WAH000000000000000", 17 "license_plate": "XY12ABC", 18 "make": "BMW", 19 "model": "X1", 20 "production_date": "2017-08-08", 21 "first_registration_date": "2017-08-09" 22 } 23}

The response will be:

 
1data = {'message': 'Thank you for the request!'} 2HTTP status = 200

This will result in the creation of a case in the Sjerlok application with the provided data. The HTTP status of the response will be 200.

 

Updating the values of the case’s overwritable fields

Payload example:

 
1{ 2 "case_number": "54321", 3 "category": "cars", 4 "disappear_date": "2018-07-05", 5 "disappear_zip_code": "321", 6 "disappear_country": "Germany", 7 "disappear_city": "Berlin", 8 "theft_report_number": "123", 9 "case_note": "Lost object!", 10 "object_owner": { 11 "phone_number": "+31612341200", 12 "email": "other.owner.email@emailhost.com", 13 "name": "Other owner Name" 14 }, 15 "object_data": { 16 "vin": "WAH000000000000000", 17 "license_plate": "XY12ABC", 18 "make": "BMW", 19 "model": "X1", 20 "production_date": "2017-08-08", 21 "first_registration_date": "2017-08-09" 22 } 23}

The result will be:

 
1data = {'message': 'Thank you for the request!'} 2HTTP status = 200

First of all, please keep in mind that the only fields that are available to be updated are the following:

 
1number 2disappear_date 3disappear_zip_code 4disappear_city 5disappear_country 6object_owner__name 7object_owner__email 8object_owner__phone_number 9contact_details_provided

Any other value provided for the other fields will be ingored and the inital value will be kept. Also please pay attention that when wanting to update a case values the same VIN and License plate have to be used in order to crrectly identify the targeted case. Failing so will result in the creation of a new case

 

Sending a request with an empty payload will result in an error detailing the mandatory fields

Payload example:

 
1{}

The response will be:

 
1data = { 2 'disappear_date': 'This field is mandatory', 3 'case_number': 'This field is mandatory', 4 'object_data': 'This field is mandatory' 5} 6HTTP status = 400

The response will contain all the mandatory first level fields that must be provided in order to process the information. In this case disappear_date, case_number, object_data as per the table above detailing all the available fields. Note that in this case, the HTTP status of the response will be 400.

 

Sending a request with an invalid model name will create the case and send an email with the incorrect value

Payload example:

 
1{ 2 "case_number": "12345", 3 "category": "cars", 4 "disappear_date": "2017-07-05", 5 "disappear_zip_code": "123", 6 "disappear_country": "Romania", 7 "disappear_city": "Bucharest", 8 "theft_report_number": "123", 9 "case_note": "Lost object!", 10 "object_owner": { 11 "phone_number": "+31612341234", 12 "email": "owner.email@emailhost.com", 13 "name": "Owner Name" 14 }, 15 "object_data": { 16 "vin": "WAH000000000000000", 17 "license_plate": "XY12ABC", 18 "make": "BMW", 19 "model": "totally_not_a_real_model_name", 20 "production_date": "2017-08-08", 21 "first_registration_date": "2017-08-09" 22 } 23}

The response will be:

 
1data = {'message': 'Thank you for the request!'} 2HTTP status = 200

This will create a case in the Sjerlok application, but it will not contain the model information since it was not possible to identify it in our internal data structure containing these kinds of information related to aspects like make, model, version, etc.

Due to this, the application will send an email noticing about the incorrect value provided, but it will also store this information in the case notes such that it can be further investigated manually.

 

Overlooking the category field from the request will create the case and try to infer the value of category

Payload example:

 
1{ 2 "case_number": "12345", 3 "disappear_date": "2017-07-05", 4 "disappear_zip_code": "123", 5 "disappear_country": "Romania", 6 "disappear_city": "Bucharest", 7 "theft_report_number": "123", 8 "case_note": "Lost object!", 9 "object_owner": { 10 "phone_number": "+31612341234", 11 "email": "owner.email@emailhost.com", 12 "name": "Owner Name" 13 }, 14 "object_data": { 15 "vin": "WAH000000000000000", 16 "license_plate": "XY12ABC", 17 "make": "BMW", 18 "model": "X1", 19 "production_date": "2017-08-08", 20 "first_registration_date": "2017-08-09" 21 } 22}

The response will be:

 
1data = {'message': 'Thank you for the request!'} 2HTTP status = 200

The request will create a case, and the case object will have a category value assigned to it. This is due to the fact that the category can be inferred based on the other fields of the object_data, namely the make and model fields. This is done using our hierarchical internal structure for the value of these fields and thus determine that the BMW values is under the Cars category, automatically filling this missing information.

 

Overlooking the category field, and the model field from the request, but the make field has enough information to infer the model. This will, in return, be used to infer the category as well when the case is created.

Payload example:

 
1{ 2 "case_number": "12345", 3 "disappear_date": "2017-07-05", 4 "disappear_zip_code": "123", 5 "disappear_country": "Romania", 6 "disappear_city": "Bucharest", 7 "theft_report_number": "123", 8 "case_note": "Lost object!", 9 "object_owner": { 10 "phone_number": "+31612341234", 11 "email": "owner.email@emailhost.com", 12 "name": "Owner Name" 13 }, 14 "object_data": { 15 "vin": "WAH000000000000000", 16 "license_plate": "XY12ABC", 17 "make": "Bmw X1 TDI 2.0 Bluemotion", 18 "production_date": "2017-08-08", 19 "first_registration_date": "2017-08-09" 20 } 21}

The response will be:

 
1data = {'message': 'Thank you for the request!'} 2HTTP status = 200

The request will result in the creation of a case due to several factors. As per the previous use case, using our hierarchical internal structure, it will identify based on the value of the make field that the value for the model field is in fact X1. Next, using these two values, it will proceed to infer the category as it does in the previously described use case.

 

The company of the case will be set as the current company based on the token used to authenticate the requesting user

Payload example:

 
1{ 2 "case_number": "12345", 3 "category": "cars", 4 "disappear_date": "2017-07-05", 5 "disappear_zip_code": "123", 6 "disappear_country": "Romania", 7 "disappear_city": "Bucharest", 8 "theft_report_number": "123", 9 "case_note": "Lost object!", 10 "object_owner": { 11 "phone_number": "+31612341234", 12 "email": "owner.email@emailhost.com", 13 "name": "Owner Name" 14 }, 15 "object_data": { 16 "vin": "WAH000000000000000", 17 "license_plate": "XY12ABC", 18 "make": "BMW", 19 "model": "X1", 20 "production_date": "2017-08-08", 21 "first_registration_date": "2017-08-09" 22 } 23}

The response will be:

 
1data = {'message': 'Thank you for the request!'} 2HTTP status = 200

This will create the case in the Sjerlok application and will automatically fill the information about the case company based oh the authentication token used to authorize the request. The company will be the current/active company set for the user at the moment that the request is sent.

 

Sending a request overlooking both VIN, and License Place fields for the Case Object will result in an error response

Payload example:

 
1{ 2 "case_number": "12345", 3 "category": "cars", 4 "disappear_date": "2017-07-05", 5 "disappear_zip_code": "123", 6 "disappear_country": "Romania", 7 "disappear_city": "Bucharest", 8 "theft_report_number": "123", 9 "case_note": "Lost object!", 10 "object_owner": { 11 "phone_number": "+31612341234", 12 "email": "owner.email@emailhost.com", 13 "name": "Owner Name" 14 }, 15 "object_data": { 16 "make": "BMW", 17 "model": "X1", 18 "production_date": "2017-08-08", 19 "first_registration_date": "2017-08-09" 20 } 21}

The response will be:

 
1data = { 2 'object_data': { 3 'vin': 'At least one, but preferably both, of the fields vin or license plate should be provided', 4 'license_plate': 'At least one, but preferably both, of the fields vin or license plate should be provided' 5 } 6} 7HTTP status = 400

The fields VIN, and License plate are required in order to uniquely identify the cases in our system. Furthermore, these are required in order to identify the case when the user wants to update some of its values. In an ideal world, it is prefed for both the fields to be present in the request, although one of them woudl be enough.

Therefore, skiping both of these fields will result in an error response.

When only one of them is skipped, it will result in creating a case, but the missing information will not be present in the case’s details.

 

Sending a request and overlooking the make field for the Case Object will result in an error response

Payload example:

 
1{ 2 "case_number": "12345", 3 "category": "cars", 4 "disappear_date": "2017-07-05", 5 "disappear_zip_code": "123", 6 "disappear_country": "Romania", 7 "disappear_city": "Bucharest", 8 "theft_report_number": "123", 9 "case_note": "Lost object!", 10 "object_owner": { 11 "phone_number": "+31612341234", 12 "email": "owner.email@emailhost.com", 13 "name": "Owner Name" 14 }, 15 "object_data": { 16 "vin": "WAH000000000000000", 17 "license_plate": "XY12ABC", 18 "model": "X1", 19 "production_date": "2017-08-08", 20 "first_registration_date": "2017-08-09" 21 } 22}

The response will be:

 
1data = {'object_data': {'make': 'This field is mandatory'}} 2HTTP status = 400

Skiping the make field from the object_data will result in an error due to the fact that the object can not be placed inside out internal hierarchical internal structure.