1- LOGIN

REST istemci olarak j-Platform da tanımlı kullanıcı bilgileri ile login olunur ve bir token alınır. Sonraki işlemlerde auth-token (client token:token:user) kullanılır. 

REST İstemcisi (postman) ile aşağıdaki parametreler kullanılarak istekte bulunabilirsiniz.

Required Informations
Method : POST
Host + Login Path : http://localhost:8080/logo/restservices/rest/login

Header Parametreleri : 
 accept : application/json
 authorization : Basic YWRtaW46bG9nbzEyOjE6MTpdUUlRSs
 emulating : true

Örnek Authorization (Base64 encode için : https://www.base64decode.org/)

  • Basic BASE64Encode(user:password:ClientToken:Firm:TRTR)
  • Basic BASE64Encode(admin:logo12:1:1:TRTR)
Login Response
{
"success": true,
"serviceKey": null,
"authToken": "3e11f7fa1206775136",
"authorization": "Basic YWRtaW46bG9nbzEyOjE6MTpdUUlRSs",
"service": 0
}
Login Request in JAVA
url = new URL("http://localhost:8080/logo/restservices/rest/login");
System.out.println(url);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
CLIENT_TOKEN = UUID.randomUUID().toString();
String header = userName+":" +password+ ":" + CLIENT_TOKEN + ":" + firmNo + ":TRTR";
//admin:logo12:f87ee0de-3402-4171-903e-fd26e666889d:1:TRTR
String basicAuth = "Basic " + Base64.getEncoder().encodeToString(header.getBytes());
conn.setRequestProperty("Authorization", basicAuth);
conn.setRequestProperty("emulating", true); // Rest v2.0 ile yalnızca M-WEBSERVISUSER lisansı tüketerek işlem yapabilmek için eklenen header. Aksi takdirde P-STD lisansı ihtiyacı doğuyor.
Login Request in C#
string HEADER = USER_NAME + ":" + PASSWORD + ":" + CLIENT_TOKEN + ":" + FIRM_NO + ":" + LANGUAGE;
//admin:logo12:f87ee0de-3402-4171-903e-fd26e666889d:1:TRTR
string basicAuth = "Basic " + System.Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(HEADER));
HttpWebRequest webrequest = (HttpWebRequest)System.Net.WebRequest.Create("http://localhost:8080/logo/restservices/rest/login");
webrequest.Method = "POST";
webrequest.Accept = "application/json";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("Authorization", basicAuth);
webrequest.Headers.Add("emulating", true); // Rest v2.0 ile yalnızca M-WEBSERVISUSER lisansı tüketerek işlem yapabilmek için eklenen header. Aksi takdirde P-STD lisansı ihtiyacı doğuyor.


2- GET

j-Platform REST tüketim öncesi mutlaka auth-token (erişim belirteci) ifadesinin isteğin içerisinde yer alması gerekmektedir. swagger dokumantasyonu için http://localhost:8080/logo/restdocs/ adresini kullanabilirsiniz.

Required Informations
Method : GET
Host + Path : http://localhost:8080/logo/restservices/rest/v1.0/fiarpcardexchanges

Header Parametreleri : 
 accept : application/json
 auth-token: MTpmMWU1NzNhMjA2Nzc1Mzc4OmFkbWlu

Örn auth-token (Base64 encode için : https://www.base64decode.org/)

BASE64Encode(client token:auth-token:user)

BASE64Encode(1:3e11f7fa1206775136:admin)

GET Response
{
"apiVersion": "1.0","data": {"meta": {
"href": "http://localhost:8080/logo/rest/v1.0/fiarpcardexchanges"},"offset": 0,
"limit": 10,
"count": 3,
"first": {"meta": {
"href": "http://localhost:8080/logo/rest/v1.0/fiarpcardexchanges?offset=0"}},"previous": null,
"next": null,
"items": [  {"meta": {
"href": "http://localhost:8080/logo/rest/v1.0/fiarpcardexchanges/1"},"id": "1",
"fid": "",
"internal_Reference": 1,
"account_Type": 3,
"code": "18020110132482700001",
"corresp_Lang": 1
......
}
GET Request in Java
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
String header = CLIENT_TOKEN+":" + AUTH_TOKEN +":" + userName;
String basicAuth = Base64.getEncoder().encodeToString(header.getBytes());
conn.setRequestProperty ("auth-token", basicAuth);
conn.setRequestProperty( "charset", "utf-8");
GET Request in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/v1.0/fiarpcardexchanges";
WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "GET";
webrequest.ContentType = "application/json";      
webrequest.Headers.Add("auth-token", getEncodedAuthToken());

Get İşleminde Döndürülen Kayıt Limitini Arttırma 

1-) Tomcat debug modda başlatılır.

2-) localhost:port/logo/Status alanına girilir

3-) Menüden Configs açılır ve sonrasında ServerConfig dosyası seçilir.

4-) Data Layer kategorisinin içerisine aşağıdaki parametre yapıştırılır. (Aşağıdaki kod parçasında limit 10000 olarak ayarlanmıştır)

<parameter admin="true" description="" enabled="true" name="RestExecuteMaxRowLimit" sadmin="true" side="s" t="setter">
<property description="" name="class-name" t="s" value="com.lbs.data.factory.ServerFactory2" />
<property description="" name="value" t="i" value="10000" />
<property description="" name="field-name" t="s" value="REST_EXECUTE_MAX_ROW_LIMIT" />
</parameter>

5-)Kaydedip Get işlemini gerçekleştirebilirsiniz.


Yapılış Videosu

3- POST

j-Platform REST tüketim öncesi mutlaka auth-token (erişim belirteci) ifadesinin isteğin içerisinde yer alması gerekmektedir. swagger dokumantasyonu için http://localhost:8080/logo/restdocs/ adresini kullanabilirsiniz.

Required Informations
Method : POST
Host + Path : http://localhost:8080/logo/restservices/rest/v1.0/fiarpcardexchanges

Header Parametreleri : 
 accept : application/json
 auth-token: MTpmMWU1NzNhMjA2Nzc1Mzc4OmFkbWlu

Body:
{  
   "account_Type":3,
   "code": "KOD",
   "title":"UNVAN",
   "address1":"ADRES BILGISI",
   "city":"Adana",
   "country":"Türkiye",
   "telephone1":"TEL1",
   "telephone2":"TEL2",
   "mobilePhone":"TEL3",
   "fax":"FAX",
   "tax_Office":"VERGIDAIRESI",
}
POST Response
{
    "apiVersion": "1.0",
    "data": {"meta": {"href": "http:\/\/localhost:8090\/logo\/rest\/v1.0\/fiarpcardexchanges\/1345"}}
}
POST Request in Java
URL url = new URL("http://localhost:8080/logo/restservices/rest/v1.0/fiarpcardexchanges");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("auth-token", getEncodedAuthToken());
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
os.write(RequestBody.getBytes());
os.flush();
os.close();
POST Request in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/v1.0/fiarpcardexchanges";

var postData = Encoding.ASCII.GetBytes(POSTRequestBodyEntry.Text);

WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "POST";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("auth-token", getEncodedAuthToken());


4- PUT

PUT Metodunu çalıştırırken Request Body'ye Güncellenecek kartın tüm alanları ile birlikte GET edilmiş JSON'ı yazılır.

Required Informations
Method : PUT
Host + Path : http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/[id]

Header Parametreleri : 
 accept : application/json
 auth-token: MTpmMWU1NzNhMjA2Nzc1Mzc4OmFkbWlu

Body:
{  
   //Kartın tüm alanları ile birlikte GET edilmiş JSON'ı üzerinde değiştirmek istediğiniz alanları değiştirip isteği gönderebilirsiniz.
}
PUT Response
{
    "apiVersion": "1.0",
    "data": {"meta": {"href": "http://localhost:8090/logo/rest/v1.0/mmitemexchanges/[id]"}}
}
PUT Request in Java
URL url = new URL("http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/2"); //2 id'li kart güncellenecek
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("PUT");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("auth-token", getEncodedAuthToken());
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
os.write(RequestBody.getBytes());
os.flush();
os.close();
PUT Request in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/2"; //2 id'li kart güncellenecek

var putData = Encoding.ASCII.GetBytes(PUTRequestBody.Text);

WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "PUT";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("auth-token", getEncodedAuthToken());


5- PATCH

PATCH Metodunu çalıştırırken Request Body'ye Güncellenecek kartın yalnızca güncellenecek alanlarının JSON karşılıkları yazılır.

Required Informations
Method : PUT
Host + Path : http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/patch/[id]

Header Parametreleri : 
 accept : application/json
 auth-token: MTpmMWU1NzNhMjA2Nzc1Mzc4OmFkbWlu

Body:
{  
   "name": "ORNEK DENEME" 		//yalnızca name alanını değiştirmek istiyorsak.
}
PATCH Response
{
    "apiVersion": "1.0",
    "data": {"meta": {"href": "http://localhost:8090/logo/rest/v1.0/mmitemexchanges/[id]"}}
}
PATCH Request in Java
URL url = new URL("http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/patch/2"); //2 id'li kart güncellenecek
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("PUT");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("auth-token", getEncodedAuthToken());
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
os.write(RequestBody.getBytes());
os.flush();
os.close();
PATCH Request in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/patch/2"; //2 id'li kart güncellenecek

var patchData = Encoding.ASCII.GetBytes(PATCHRequestBody.Text);

WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "PUT";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("auth-token", getEncodedAuthToken());


6- DELETE

Required Informations
Method : DELETE
Host + Login Path : http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/[id]

Header Parametreleri : 
 accept : application/json
 auth-token: YWRtaW46bG9nbzEyOjE6MTpdUUlRSs
Delete Request in Java
conn.setRequestMethod("DELETE");
conn.setRequestProperty("Accept", "application/json");
String header = CLIENT_TOKEN+":" + AUTH_TOKEN +":"+userName;
String basicAuth = Base64.getEncoder().encodeToString(header.getBytes());
conn.setRequestProperty ("auth-token", basicAuth);
Delete Request in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/v1.0/mmitemexchanges/2"; //2 ID'li Kart silinecek
WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "DELETE";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("auth-token", getEncodedAuthToken());


7- LOGOUT

Required Informations
Method : POST
Host + Login Path : http://localhost:8080/logo/restservices/rest/logout

Header Parametreleri : 
 auth-token: MTpmMWU1NzNhMjA2Nzc1Mzc4OmFkbWlu
Logout Response
{
"success": true,
"serviceKey": null,
"authToken": null,
"authorization": null,
"service": 1
}
Logout Request in Java
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
String header = CLIENT_TOKEN+":" + AUTH_TOKEN +":"+userName;
String basicAuth = Base64.getEncoder().encodeToString(header.getBytes());
conn.setRequestProperty ("auth-token", basicAuth);
Logout Request in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/logout";
WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "POST";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("auth-token", getEncodedAuthToken());


8- SQL/SELECT

Required Informations
Method : POST
Host + Login Path : http://localhost:8080/logo/restservices/rest/dataQuery/executeSelectQuery

Header Parametreleri : 
 accept : application/json
 auth-token: YWRtaW46bG9nbzEyOjE6MTpdUUlRSs

Body:
{
  "jsonFormat": 1,
  "querySqlText": "SELECT LOGICALREF FROM U_001_ITEMS",
  "maxCount": -1
}
SQL Response
{
  "successful": true,
  "errorMessage": null,
  "rows": [
    {
      "LOGICALREF": 6
    },
    {
      "LOGICALREF": 8
    },
    {
      "LOGICALREF": 61
    },
    {
      "LOGICALREF": 64
    },
    {
      "LOGICALREF": 65
    },
    {
      "LOGICALREF": 66
    },
    {
      "LOGICALREF": 67
    }
  ],
  "__equalsCalc": null,
  "__hashCodeCalc": false
}
SQL Select in Java
URL url = new URL("http://localhost:8080/logo/restservices/rest/dataQuery/executeSelectQuery");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("auth-token", getEncodedAuthToken());
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
os.write(RequestBody.getBytes());
os.flush();
os.close();
SQL Select in C#
string urlPathForRequest = "http://localhost:8080/logo/restservices/rest/dataQuery/executeSelectQuery";

var postData = Encoding.ASCII.GetBytes(RequestBody);

WebRequest webrequest = WebRequest.Create(urlPathForRequest);
webrequest.Method = "POST";
webrequest.ContentType = "application/json";
webrequest.Headers.Add("auth-token", getEncodedAuthToken());
Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım