Sorgu Controller'ı
Sorgu controller'ı sadece select ifadelerinin çalışmasına izin verir.
Kullanıcılar aşağıdaki seçenekleri aktif edebilir.
- enableJoinQuery, enableQueryUnsafe, enableQueryDatabaseAndServerIdentifier, enableQueryFunctionCall, enableQueryProcedureCall, enableQueryProcedureCall, enableQueryInsertStatement, enableQueryUpdateStatement, enableQueryMergeStatement, enableQueryDeleteStatement
Microsoft.SqlServer.TransactSql.ScriptDom kütüphanesi parse işlemleri için kullanılabilir.
Request Header
GET http://172.16.12.47:9010/api/v1/queries?tsql=SELECT%20COUNT(LOGICALREF)%20AS%20countLOGICALREF%20FROM%20LG_214_EMUHACC%20as%20p%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20WHERE%20p.CODE%20=%20'100'%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20GROUP%20BY%20p.LOGICALREF HTTP/1.1
Authorization:
Bearer
AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAbat9TDrC10W80Hh3PoYXZwAAAAACAAAAAAADZgAAwAAAABAAAACHSS9_xmi5qvdb5LT_dqh8AAAAAASAAACgAAAAEAAAAIew2SOMqkxSNz-wjclaMSCoAAAAg0gXedmf6mbBmkkY-94ykGSFvZzjGAfZR4XugeOEIKqSaxs_cIJYYPxnirtzvcvnoSQEiuRIIV9iQs443wtchnKVQ4DxiUWgRCR9W3PYAIHphMWgqC-ylhEyjHwDrpzAznyufP_GtIXKfjy2SnWET3K3xxnN91XWarD66MzaDctx42RHplhNZ0eBmSq2V219nb5WJFTQq6F6QNsutk4PIhEFY_ZTjk2CFAAAAFwHGq3PA3kqwBVuMC3u8DrDWnpY
Accept: application/json, application/octet-stream
Host: 172.16.12.47:9010
Request Body
boş
Response Header
HTTP/1.1 200 OK
Content-Length: 374
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Wed, 27 May 2015 06:31:32 GMT
Response Body
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/queries?tsql=SELECT
COUNT(LOGICALREF) AS countLOGICALREF FROM LG_214_EMUHACC as p
%0D%0A WHERE p.CODE = '100'
%0D%0A GROUP BY p.LOGICALREF",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "v1"
},
"count": 1,
"items": [{
"countLOGICALREF": 1
}]
}
Service Controller'ı
Service Controller, REST servisi hakkında bilgi toplamak için kullanılır. Temel dokumanı en kolay yoldan oluşturabiliriz.
Swagger 2.0, REST servislerin kendi tanımlarını oluşturmak için kullanılııyor.
Kullanıma yönelik olarak üç tip servis tanımı vardır.
- api/v1/services?expandLevel=full tüm REST servis Swagger 2.0 dokümantasyonunu döner. (Eğer REST model tanımlarına gerek yoksa, "api/v1/services" expandLevel parametresi kullanılmaz)
- api/v1/services/describe controller lisesini döner. Kullanıcı detaylı bilgi için controller içindeki metod tanımlarını çağırabilirler.
- api/v1/services/[serviceName] mevcut servis hakkında detaylı bilgi döner. (Swagger tanımı verilen servis ismine göre filtrelenir. expandLevel main services çağrısı ile aynı olmalıdır.)
Service controller çağrısı sonuncu dönen JSON swagger özellikleri ile oluşturulur. (http://swagger.io/)
Swashbuckle library v.5.2.1 API kullanılmaktadır. (https://www.nuget.org/packages/Swashbuckle)
REST Yanıt Sıkıştırma Fonksiyonu
REST servis çağrısı default olarak herhangi bir sıkıştırma yapmaz. Eğer sıkıştırmaya ihtiyaç duyuluyorsa, başlıktaki sıkıştırma tag'i set edilmelidir.
Sıkıştırma fonksiyonu Microsoft.ASP.NET Web API Compression 1.3.0 tarafından desteklenir. https://www.nuget.org/packages/Microsoft.AspNet.WebApi.MessageHandlers.Compression/
Request Header
GET http://172.16.12.47:9010/api/v1/services?expandLevel=full HTTP/1.1
Authorization:
Bearer
AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAbat9TDrC10W80Hh3PoYXZwAAAAACAAAAAAADZgAAwAAAABAAAACHSS9_xmi5qvdb5LT_dqh8AAAAAASAAACgAAAAEAAAAIew2SOMqkxSNz-wjclaMSCoAAAAg0gXedmf6mbBmkkY-94ykGSFvZzjGAfZR4XugeOEIKqSaxs_cIJYYPxnirtzvcvnoSQEiuRIIV9iQs443wtchnKVQ4DxiUWgRCR9W3PYAIHphMWgqC-ylhEyjHwDrpzAznyufP_GtIXKfjy2SnWET3K3xxnN91XWarD66MzaDctx42RHplhNZ0eBmSq2V219nb5WJFTQq6F6QNsutk4PIhEFY_ZTjk2CFAAAAFwHGq3PA3kqwBVuMC3u8DrDWnpY
Accept-Encoding: gzip
Eğer başlıkta "Accept-Encoding" set edilmez ise, REST çağrı default olarak sıkıştırılmaz.
gzip ve deflatealgoritmaları desteklenir.
URL QUERY PARAMETERS
Aşağıdaki URL parametreleri desteklenmektedir.
Limit: (Get Object List With Limited Record Size, If not given default limit size will be used)
http://localhost:9010/api/doglaccount?limit=20
First: (Get Object At The Last Index, if no sort defined logical reference is the sort order)
http://localhost:9010/api/doglaccount?first=true
Last: (Get Object At The Last Index, if no sort defined logical reference is the sort order)
http://localhost:9010/api/doglaccount?last=true
Offset: (Get Object At Index Of Sort Order, if no sort defined logical reference is the sort order, default offset is 0)
http://localhost:9010/api/doglaccount?offset=10
Sort: (Get By Sort Order)
http://localhost:9010/api/doglaccount?sort=CODE
http://localhost:9010/api/doglaccount?sort=CODE desc,DESCRIPTION
Fields: (Filtering Fields)
http://localhost:9010/api/doglaccount?fields=CODE
ExpandLevel: (ExpandLevel can be full or empty. Default empty. ExpandLevel full will retrieve all subobjects of parent object)1
http://localhost:9010/api/salesorders?expandLevel=full
Expand: (If expandLevel is full, expand can be used for subobjects filter. Default empty which means all subobjects)
http://localhost:9010/api/salesorders?expandLevel=full&expand=TRANSACTIONS
Count: (Returns only the total calculated query result object count)
http://localhost:9010/api/doglaccount?count=true
Q: (Returns query criterias result objects defined as q)
http://localhost:9010/api/doglaccount?q=CODE gt ‘100’ and CODE lt ‘200’
WithCount: (Returns the total calculated query result object count with actual query result)
http://localhost:9010/api/doglaccount?limit=10&withCount=true
Örnek Çağrı
Request Header
GET http://172.16.12.47:9010/api/v1/doglaccount?limit=10&offset=10&fields=INTERNAL_REFERENCE,DESCRIPTION&withCount=true HTTP/1.1
Authorization:
Bearer
AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAbat9TDrC10W80Hh3PoYXZwAAAAACAAAAAAADZgAAwAAAABAAAADl6E7NDfnEj1PCPs8fo6tDAAAAAASAAACgAAAAEAAAAHF-J0Qa1mn6lYm9zkmGRCOoAAAApL2o5X72WS4aLqMiwZn6RRLrxsQc50PGE3HmKjhPpY52emmcuA6Gj3FsB8zzrKzERAuyLqn--6AOSfgoTXaMoSikX9uasLvMcwiYoXOlT3VAx3xv02MH1CS--dz-W_vtjuIJ4bgoPi8fPc_UhbiQm9eZLxyQeJx3DDM2AhFxrCLrGVbqWOYaJCQFormtd_itdxLdmgHFgXzMQ6zPNx2VFA2veLydBl50FAAAANzZnAPEUuqe-tKdubBoWB-w4gUo
Accept: application/json, application/octet-stream
Host: 172.16.12.47:9010
Request Body
empty
Response Header
HTTP/1.1 200 OK
Content-Length: 4441
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Wed, 27 May 2015 06:34:16 GMT
Response Body
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doglaccount?offset=10&limit=10&fields=INTERNAL_REFERENCE,DESCRIPTION&withCount=true",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"offset": 10,
"count": 10,
"totalCount": 1530,
"limit": 10,
"first": {
"href": "http://172.16.12.47:9010/api/v1/doglaccount?limit=10&fields=INTERNAL_REFERENCE,DESCRIPTION&withCount=true",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"next": {
"href": "http://172.16.12.47:9010/api/v1/doglaccount?offset=20&limit=10&fields=INTERNAL_REFERENCE,DESCRIPTION&withCount=true",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"previous": {
"href": "http://172.16.12.47:9010/api/v1/doglaccount?limit=10&fields=INTERNAL_REFERENCE,DESCRIPTION&withCount=true",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"items": [{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/12",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 12,
"DESCRIPTION": "ALICILAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/12/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/13",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 13,
"DESCRIPTION": "ALACAK SENETLERİ",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/13/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/14",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 14,
"DESCRIPTION": "ALACAK SENETLERİ REESKONTU (-)",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/14/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/15",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 15,
"DESCRIPTION": "VERİLEN DEPOZİTO VE TEMİNATLAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/15/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/16",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 16,
"DESCRIPTION": "DİĞER TİCARİ ALACAKLAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/16/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/17",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 17,
"DESCRIPTION": "ŞÜPHELİ TİCARİ ALACAKLAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/17/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/18",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 18,
"DESCRIPTION": "ŞÜPHELİ TİCARİ ALACAKLAR KARŞILIĞI (-)",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/18/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/19",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 19,
"DESCRIPTION": "ORTAKLARDAN ALACAKLAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/19/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/20",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 20,
"DESCRIPTION": "İŞTİRAKLERDEN ALACAKLAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/20/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
},
{
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/21",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
},
"INTERNAL_REFERENCE": 21,
"DESCRIPTION": "BAĞLI ORTAKLIKLARDAN ALACAKLAR",
"DEFNFLDSLIST": {
"Meta": {
"href": "http://172.16.12.47:9010/api/v1/doGLAccount/21/DEFNFLDSLIST",
"mediaType": "application/json; charset=UTF-8",
"apiVersion": "1.0"
}
}
}]
}