1- Login
j-guar is logged in with user-defined information and a token is received. AuthToken () is used for subsequent operations. With REST Client (postman) you can request using the following parameters.
Login Post Request
Method : POST
Host + Login Path : http://localhost:8080/logo/restservices/rest/login
Header Parametreleri :
accept : application/json
authorization : Basic YWRtaW46bG9nbzEyOjE6MTpdUUlRSs
Example Authorization (Base64 encode için : https://www.base64decode.org/)
- Basic BASE64Encode(user:password:ClientToken:Firm:TRTR)
- Basic BASE64Encode(admin:logo12:1:1:TRTR)
Response
{
"success": true,
"serviceKey": null,
"authToken": "3e11f7fa1206775136",
"authorization": "Basic YWRtaW46bG9nbzEyOjE6MTpdUUlRSs",
"service": 0
}
Login Post Request Java
url = new URL(restAuthInfo.getUrl().substring(0, restAuthInfo.getUrl().length()-5)+BASE_END_POINT+"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 = restAuthInfo.getUserName()+":" +restAuthInfo.getPassword() + ":" + CLIENT_TOKEN + ":" +restAuthInfo.getFirmNo() + ":TRTR";
String basicAuth = "Basic " + Base64.getEncoder().encodeToString(header.getBytes());
conn.setRequestProperty("Authorization", basicAuth);
2- GET
GET Cari/ARP
Method : GET
Host + Path : http://localhost:8080/logo/rest/v1.0/fiarpcardexchanges
Header Parametreleri :
accept : application/json
auth-token: MTpmMWU1NzNhMjA2Nzc1Mzc4OmFkbWlu
Eg: auth-token (For Base64 encoding : https://www.base64decode.org/)
BASE64Encode(client token:auth-token:user)
BASE64Encode(1:3e11f7fa1206775136:admin)
GET 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");
Response:
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
......
}
3- POST
POST ARP/Cari
Method : POST
Host + Path : http://localhost:8080/logo/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",
}
Response
{
"apiVersion": "1.0",
"data": {"meta": {"href": "http:\/\/localhost:8090\/logo\/rest\/v1.0\/fiarpcardexchanges\/1345"}}
}
4- Logout
Method : POST
Host + Login Path : http://localhost:8080/logo/restservices/rest/logout
Header Parametreleri :
accept : application/json
auth-token: Basic YWRtaW46bG9nbzEyOjE6MTpdUUlRSs
Logout Java
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
String header = CLIENT_TOKEN+":" + AUTH_TOKEN +":"+restAuthInfo.getUserName();
String basicAuth = Base64.getEncoder().encodeToString(header.getBytes());
conn.setRequestProperty ("auth-token", basicAuth);
Logout Response
{
"success": true,
"serviceKey": null,
"authToken": null,
"authorization": null,
"service": 1
}
Copyright © 2018 Logo Yazılım