# M18 Core Web Services

Version: 1.0 | Release Date: 14/8/2018

# CRUD Web Services of Entities

An entity means a record in a M18 module, the following web services related to entities are provided:

  • Create
  • Read
  • Update
  • Delete

# Create Entity

Get an empty SqlEntity of a specific module.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/entity/create/employee?menuCode=employee")
  .post()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

POST http://[server]/jsf/rfws/entity/create/[module]?menuCode=[menuCode]

# Parameters

Name Type Description
authorization String(Header) Required. Access token obtained via OAuth
client_id String(Header) Required. Client ID in M18 [OAuth Applications]
module String(Path) Required. Module type, can be found in data dictionary.
menuCode String(Query) Required. Menu code, such as 'employee', can be found in data dictionary.
param json String(Query) Additional parameters for special actions.

# Result

If API runs success, status of the response will be 200, then it will return an empty SqlEntity. If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body An empty SqlEntity
fail Header(error_id=1) Multiple errors with JSON array format
fail Header(error_info) A CheckMsg JSON array

# Read Entity

Get an existing SQLEntity of a specific module.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/entity/read/employee?menuCode=employee&id=1")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/entity/read/[module]?menuCode=[menuCode]&id=[id]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via OAuth
client_id String(Header) Required. Client ID in M18 [OAuth Applications]
module String(Path) **Required. **Module type, such as 'employee', can be found in data dictionary
menuCode String(Query) Required. Menu code, such as 'employee', can be found in data dictionary
id long(Query) Required. ID of the entity.
param json String(Query) Additional parameters for special actions
iRev int(Query) If you want to read the old version of the entity, please set this value. If you want to read a delete entity, please set the id and iRev of the delete entity.

# Result

If API runs success, status of the response will be 200, then it will return a correct SqlEntity of this module. If API runs failed, status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body A correct SqlEntity
fail Header(error_id=1) Multiple errors with JSON array format
fail Header(error_info) A CheckMsg JSON array

# Save Entity

Save a SqlEntity to a specific module.

OkHttpClient client = new OkHttpClient();

MediaType jsonMT = MediaType.parse("application/json; charset=utf-8");
RequestBody rb = RequestBody.create(jsonMT, 
                 "[Simplified Entity JSON]" or "array of [Simplified Entity JSON]");

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/entity/s/save/employee?menuCode=employee")
  .put(formBody)
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

PUT http://[server]/jsf/rfws/entity/s/save/[module]?menuCode=[menuCode]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via OAuth
client_id String(Header) Required. Client ID in M18 [OAuth Applications]
module String(Path) **Required. **Module type,such as 'employee', can be found in data dictionary.
menuCode String(Query) Required. Menu code, such as 'employee', can be found in data dictionary.
param jsonString(Query) Additional parameters for special actions.
entity jsonString(Query) The Simplified Entity JSON, structure please refer to the below. Notice that the JSON need to be URL Encoded.
entitys_in_entity String(Body) The Simplified Entity JSON, structure please refer to the below. It is recommended to pass entity JSON in request body.If you want to handle more entitys, please pass an array of Simplified Entity JSON.

# Simplified Entity JSON

{
	"employeepic": {
		"values": []
	},
	"employee_attach": {
		"values": []
	},
	"employee": {
		"values": [
          {"code": "000171","desc": "abcd"}
        ]
	}
}
  • The JSON contains objects of different tables in a module, each table contains a "values" JSON array to specify the value of each field in the table.
  • The main table of a module is compulsory. For which table is main users can refer to data dictionary.
  • If a table or the value for a field are not provided, they will not be saved.

# Result

If API runs success, status of the response will be 200, then it will return a correct id of this SqlEntity. If API run failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body ID of the saved SqlEntity
fail Header(error_id=1) Multiple errors with JSON array format
fail Header(error_info) A CheckMsg JSON array

# Delete Entity

Delete a SqlEntity from a specific module.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/entity/delete/employee?menuCode=employee&id=1")
  .delete()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

DELETE http://[server]/jsf/rfws/entity/delete/[module]?menuCode=[menuCode]&id=[id]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via OAuth
client_id String(Header) Required. Client ID in M18 [OAuth Applications]
module String(Path) **Required. **Module type,such as 'employee', can be found in data dictionary
menuCode String(Query) Required. Menu code, such as 'employee', can be found in data dictionary
id long(Query) Required. ID of the entity
param json String(Query) Additional parameters for special actions

# Result

If API runs success, status of the response will be 200. If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Status Status is 200
fail Header(error_id=1) Multiple errors with JSON array format
fail Header(error_info) A CheckMsg JSON array

# Get ID by Code Web Service

Get entity ID using record's code in a module.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/entity/getIdByCode/employee?menuCode=employee&code=001")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/entity/getIdByCode/[module]?menuCode=[menuCode]&code=[record code]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via OAuth
client_id String(Header) Required. Client ID in M18 [OAuth Applications]
module String(Path) Required. Module type, such as 'employee', can be found in Data Dictionary.
menuCode String(Query) Menu code of the editor, can be found in Data Dictionary.
code string(Query) Required. The code of the record.
beId int(Query) If the module is BE specific, need to provide the beID. BE means Business Entity in M18, which is a [Department] record with BE check box ticked.

# Result

If API runs success, status of the response will be 200, then it will return a JSON object. The JSON object includes id, withRight and withMulti. The type of id is long. The type of withRight and withMulti is boolean. When withRight is true, it means the current user can visit this record. When withMulti is true, it means two or more records are using this code.

If API runs failed, status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body A JSON object includes the ID, withRight and withMulti.
fail Header(error_id=1) Multiple errors with JSON array format
fail Header(error_info) A CheckMsg JSON array

# Data Search Web Service

Search data in M18 using lookup type.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/search/search?stSearch=employee&startRow=1&endRow=10")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/search/search?stSearch=[stSearchName]&startRow=[startRow]&endRow=[endRow]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via OAuth
client_id String(Header) Required. Client ID in M18 [OAuth Applications]
stSearch String(Query) Required. Lookup type, such as 'employee', can be found in Data Dictionary or UDF Lookup.
startRow int(Query) The start row of the search
endRow int(Query) The end row of the search
beId long(Query) If the search is BE specific, beId need to input
formatId long(Query) Search format ID
conds String(Query) Please check Condition Detail
sorts String(Query) Sort Fields ,split by ";". If not ascending, please use "!"; Example:"code;!desc"
resultFields String(Query) If you want to return some fields value, please this parameter.
lookupField boolean(Query) If the value is true, then the result data will be no expired,no locked, and approved.
quickSearchStr String(Query) If you want to use quick search ,please set this value.
fieldDesc boolean(Query) If the value is true, the will return the field's name and mess value.
viewDeleted boolean(Query) If you want to search the data already be deleted, Please use this value true.

# Condition Detail

Conds Format:

Id=lessThan=5=and=id=largerOrEqual=3=or=(name=contains =ss=or=name=contains=bb)

Which means:

Id<5 and id >=3 or (name like ‘%ss%’ or name like ‘%bb%’)

**Please use these formats to write the conds: **

("equal", "="),

("unequal", "<>"),

("largerThan", ">"),

("lessThan", "<"),

("largerOrEqual", ">="),

("lessOrEqual", "<="),

("contains", "like"),

("doseNotContain", "notlike"),

("in", "in"),

("notIn", "notin"),

("startWith", "like"),

("endWith", "like");

# Result

If API runs success, status of the response will be 200, then it will return a SqlTable . If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body A SqlTable
fail Header(error_info) A CheckMsg JSON array

# Attachment Web Services

# Get Attachment List

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/attach/getAttach?module=dept&stSearch=dept&code=ADMIN")
  .get()
  .addHeader("authorization", "Bearer OGFiZmU2ZTktMzYzMS00NjIwLWJhNGYtYWU2OGQyNTZhMmNi")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://127.0.0.1:8080/jsf/rfws/attach/getAttach?module=[module Name]&stSearch=[stSearch code]&code=[recod's code]

# Parameters

Name Type Description
authorization string(Header) Required. Access Token obtained via Oauth2
client_id string(Header) Required. When registered in [OAuth Applications], generated by the M18
module string(Query) Required. TargetFM/transaction record’s module code
code string(Query) **Required.**TargetFM/transaction record’s code
stSearch string(Query) default= module, StSearchinfo, for system usage
beId long(Query) If the module is BE specific, need to provide the beID. BE means Business Entity in M18, which is a [Department] record with BE check box ticked.

# Result

Type Location(error_id) Description
success Body A json array

json array example

[
	{"needPassword":"false",
	"code":"M18_GZWZ2017050801-FIXED.docx",
	"fileSize":823092.0,
	"author":"admin",
	"createUser":"admin",
	"remark":"",
	"id":9,
	"createUid":5,
	"desc":"M18_GZWZ2017050801-FIXED",
	"createDate":"2017/07/04 10:52:25",
	"tags":""},

	{"needPassword":"true",
	"code":"M18_GZWZ2017051801.docx",
	"fileSize":108683.0,
	"author":"admin",
	"createUser":"admin",
	"remark":"",
	"id":10,
	"createUid":5,
	"desc":"M18_GZWZ2017051801",
	"createDate":"2017/07/04 10:52:25",
	"tags":""}
]


Parameter Name Meaning
id ID of the attachment
code Code of the attachment
desc Title of the attachment
fileSize File size of the attachment
author Author of the attachment
tags Tags of the attachment
remark Remark of the attachment
createUser Create User’s username of the attachment
createUid Create User’s ID of the attachment
createDate Date of create of the attachment
needPassword Whether the file is encrypted with password or not. *

# Get Attachment File

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/attach/getFile?module=dept&stSearch=dept&code=ADMIN&id=10")
  .get()
  .addHeader("authorization", "Bearer OGFiZmU2ZTktMzYzMS00NjIwLWJhNGYtYWU2OGQyNTZhMmNi")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://127.0.0.1:8080/jsf/rfws/attach/getFile?module=[module Name]&stSearch=[stSearch code]&code=[recod's code]&id=[Attachment ID]

# Parameters

Name Type Description
authorization string(Header) Required. Access Token obtained via Oauth2
client_id string(Header) Required. When registered in [OAuth Applications], generated by the M18
module string(Query) Required. TargetFM/ transaction record’s module code
stSearch string(Query) default= module, StSearchinfo, for system usage
code string(Query) TargetFM/ transaction record’s code
Id string(Query) Required. Attachment ID
password string(Query) Required when the file is encrypted with password. Password of the attachment. This password needs to be encrypted.

# Result

If API runs success, status of the response will be 200, then it will return a file. If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body A file
fail Header(error_info) A CheckMsg JSON array

# Upload Attachment File

OkHttpClient client = new OkHttpClient();
File file = new File("C:\\script.txt");
MediaType mt = MediaType.parse("application/octet-stream");
RequestBody rb = RequestBody.create(mt, file);

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/attach/upload?module=dept&stSearch=dept&code=ADMIN&fileName=script.text&title=attachment&author=aa&tags=program;M18;script&remark=aabbcc")
  .post(rb)
  .addHeader("authorization", "Bearer OGFiZmU2ZTktMzYzMS00NjIwLWJhNGYtYWU2OGQyNTZhMmNi")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

POST http://127.0.0.1:8080/jsf/rfws/attach/upload?module=[module Name]&stSearch=[stSearch code]&code=[recod's code]&fileName=[Attachment’s filename]&title=[file name]&author=[user name]&tags=[tags]&remark=[remark]

# Parameters

Name Type Description
authorization string(Header) Required. Access Token obtained via Oauth2
client_id string(Header) Required. When registered in [OAuth Applications], generated by the M18
module string(Query) Required. TargetFM/ transaction record’s module code
stSearch string(Query) default = module, StSearchinfo, for system usage
code string(Query) TargetFM/transaction record’s code
fileName string(Query) Required. Attachment’sfilename
title string(Query) Required. Filename (will be used as attachment code as in current system logic)
author string(Query) default = current user’s username. Author of the attachment
tags string(Query) Tags of the attachment
remark string(Query) Remark of the attachment
overwrite boolean(Query) Whether replace the first attachment of the same file name in the record. If set to true, it will search the current attachment list, and replace the first matched attachment with the same attachment code. If set to false, it will always append to the attachment list
password string(Query) Password is needed to encrypt or not. *
beId long(Query) If the module is BE specific, need to provide the beID. BE means Business Entity in M18, which is a [Department] record with BE check box ticked.

# Result

If API runs success, status of the response will be 200. If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body status 200
fail Header(error_info) A CheckMsg

# Method to Transfer File Password

Note that the attachment module supports password encryption to the file. If a user would like to pass the password to encrypt or decrypt the file, the user needs to first encrypt the password for security purpose. Our system uses AES mode to encrypt the password for web service transmission.

Here are the example codes:

	private static Key aesKey = new SecretKeySpec("Mac02017Dms02017".getBytes(), "AES");

	public static String encryptDmsTransferPassword(String password) {
		try {
			Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
			// encrypt the text
			cipher.init(Cipher.ENCRYPT_MODE, aesKey);
			byte[] encrypted = cipher.doFinal(password.getBytes());
			return DatatypeConverter.printHexBinary(encrypted);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}

# Alert Web Services

# Get Alert List

Get system alert list.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/sysAlert/getList?rowLimit=10&page=1&readMode=2")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/sysAlert/getList?rowLimit=[no. of row]&page=[pagination]&readMode=[readMode]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
rowLimit int(Query) No. of row, default = 5
page int(Query) Pagination of the alert list, default = 1
readMode int(Query) readMode 0 = all, 1 = read, 2 = unread
count boolean(Query) if count is true, then it will return the count of alert

# Get Alert List by User ID

Get system alert list by user ID.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/sysAlert/getAlertList?uid=1&rowLimit=10&page=1")
  .post()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

POST http://[server]/jsf/rfws/sysAlert/getAlertList?uid=[uid]&rowLimit=[no. of row]&page=[pagination]&readMode=[readMode]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
uid long(Query) **Required. **User ID
rowLimit int(Query) No. of row, default = 5
page int(Query) Pagination of the alert list, default = 1
readMode int(Query) readMode 0 = all, 1 = read, 2 = unread
count boolean(Query) if count is true, then it will return the count of alert

# Result

If API runs success, it will return a SqlTable. If count is true, then will return the count of alert.

Location Description
Body A sqlTable json string
Header If count is true, then will return the count of alert.

# Get Alert

Get system alert.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/sysAlert/get?alertId=1")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/sysAlert/getList?alertId=[id of alert record]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
alertId long(Path) Required. id of alert record

# Result

If API runs success, it will return a SqlTable.

Location Description
Body A SqlTable JSON string

# Announcement Web Services

# Get Announcement List

Get system announcement list.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/ancm/getAncmList?page=1&pageSize=50&orderField=ancmDate&orderAsc=DESC&readMode=0")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/ancm/getAncmList?page=[pagination]&pageSize=[pageSize]&orderField=[order field]&orderAsc=[order type]&readMode=[read mode]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
pageSize int(Path) Required. Page size
page int(Query) **Required. **Pagination of the announcement list
readMode int(Query) ReadMode 0 = all, 1 = read, 2 = unread
orderField string(Query) Which field use to sort.
orderAsc String(Query) Sort type, the value can be ASC or DESC. DESC is default.
excludeIds String(Query) Exclude some announcements using this value. It can be one id, or more ids. If two or more ids, id must separate with ,
getCount boolean(Query) If getCount is true ,then it will return the count of announcement
quickSearch String(Query) if this value is not empty, it can used to search the title, public date and importance

# Result

If API runs success, it will return a SqlTable. If getCount is true, then it will return the count of the announcement list. If getCount is false, then it will return the information of the announcement list.

Location Description
Body A SqlTable JSON string

# Get Announcement

Get system announcement.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/ancm/read?ancmId=1")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/ancm/read?ancmId=[id of announcementrecord]

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
ancmId long(Path) Required. id of announcement record

# Result

If API runs success, status of the response will be 200, then it will return a SqlEntity. If API runs failed, status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON from the response header with key word 'error_info'.

Type Location Description
success Body A SqlEntity JSON string
fail Header(error_info) A CheckMsg JSON array

Given a record, return all other records associated with this record.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/telescope/getRelatedRecord/user/2")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/telescope/getRelatedRecord/{lookupType}/{recordId}

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
lookupType String(Path) Required. Search Type
recordId long(Path) Required. id of source record

# Result

If API runs success, status of the response will be 200, then it will return a JSON. If API runs failed, status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON from the response header with key word 'error_info'.

[
    {
        "ids": [
            1,
            114
        ],
        "lastModifyDate": 1553229061000,
        "module": "dept",
        "moduleDisplay": "Department"
    },
    {
        "ids": [
            182,
            120
        ],
        "lastModifyDate": 1555925150000,
        "module": "employee",
        "moduleDisplay": "Employee"
    }
]
Type Location Description
success Body A SqlEntity JSON string
fail Header(error_info) A CheckMsg JSON array

# Telescope - Get Result by Voice command

Telescope NPL trigger, return matched telescope results according to Mobile App Setup.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/telescope/telescopeNlp?tags=staff&tags=Jacky")
  .get()
  .addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://[server]/jsf/rfws/telescope/telescopeNlp?tags={keyword}

# Parameters

Name Type Description
authorization String(Header) Required. Access Token obtained via Oauth2
client_id String(Header) Required. When registered in [OAuth Applications], generated by the M18
tags String(Query) Required. Search Keyword

# Result

If API runs success, status of the response will be 200, then it will return a JSON. If API runs failed, status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON from the response header with key word 'error_info'.

{
    "stSearch": "employee",
    "formatFieldDesc": {
        "code": "",
        "desc__lang": "Name(Current Language)",
        "iRev": "Inner Version",
        "lastModifyDate": "Last Modified Time",
        "employee.lastModifyUid.simpleUser.desc__lang": "Last Modified By(Current Language)",
        "id": "",
        "desc": ""
    },
    "size": 2,
    "stSearchDisplay": "Employee",
    "values": [
        {
            "code": "Havid0012",
            "desc__lang": "Raindrop_en",
            "iRev": 11,
            "lastModifyDate": "2019-04-22 17:27:57",
            "employee.lastModifyUid.simpleUser.desc__lang": "Raindrop_en",
            "id": 382,
            "desc": "Raindrop_en",
            "st_desc": "Raindrop_en",
            "st_id": 382,
            "st_code": "Havid0012"
        },
        {
            "code": "Havid0018",
            "desc__lang": "B",
            "iRev": 8,
            "lastModifyDate": "2019-04-22 17:27:57",
            "employee.lastModifyUid.simpleUser.desc__lang": "Raindrop_en",
            "id": 398,
            "desc": "B",
            "st_desc": "B",
            "st_id": 398,
            "st_code": "Havid0018"
        }
    ],
    "fieldDesc": {
        "code": "Code",
        "st_id": "st_id",
        "st_code": "st_code",
        "desc__lang": "Name(Current Language)",
        "st_desc": "st_desc",
        "employee.lastModifyUid.simpleUser.desc__lang": "Name(Current Language)",
        "iRev": "Inner Version",
        "id": "Key ID",
        "lastModifyDate": "Last Modified Time",
        "desc": "Name"
    }
}
Type Location Description
success Body A SqlEntity JSON string
fail Header(error_info) A CheckMsg JSON array

# Document Printing Web Services

# Get PDF File

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://127.0.0.1:8080/jsf/rfws/jrPrint/fetchPdf?menuCode=employee&recId=1")
  .post()
  .addHeader("authorization", "Bearer OGFiZmU2ZTktMzYzMS00NjIwLWJhNGYtYWU2OGQyNTZhMmNi")
  .addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

# HTTP Request

GET http://127.0.0.1:8080/jsf/rfws/jrPrint/fetchPdf?menuCode=[Menu code]&recId=[Record Id]

# Parameters

Name Type Description
authorization string(Header) Required. Access Token obtained via Oauth2
client_id string(Header) Required. When registered in [OAuth Applications], generated by the M18
menuCode string(Query) Required. Menu code, such as 'employee', can be found in data dictionary.
recId long(Query) Required. ID of the entity.
printOptionId long(Query) ID of Print Options.

# Result

If API runs success, status of the response will be 200, then it will return a file. If API runs failed , status of the response will be 400, then it will return the CheckMsg. You can get a CheckMsg JSON array from the response header with key word 'error_info'.

Type Location Description
success Body A file
fail Header(error_info) A CheckMsg JSON array