harun Fişekci
|
Oct 26, 2019 10:45 AM
|
Just came
Rating:
1
Joined: May 8, 2018
Company: Profsis Yazılım Ltd. Şti. |
Hello there I want to contact a rest service from program 1c. Is there an example in the program 1c for this? I want to contact http://webservice.tsoft.com.tr http://webservice.tsoft.com.tr/rest1/console
Edited: harun Fişekci
- Oct 26, 2019 10:46 AM
|
|
|
|
Aleksandr Biryukov
|
Oct 27, 2019 06:20 PM
|
Administrator
Rating:
24
Joined: Oct 3, 2019
Company: |
Hello Harun Fişekci!
Of course, you can work with REST services - the 1C platform is perfect for this!
You may to use the HTTPConnection object. For example, it may look like a code to access your service:
Code |
---|
Token = "YourToken";
ServerName = "webservice.tsoft.com.tr";
URL = "/rest1/brand/getBrands";
Headers = New Map;
Headers.Insert("token", Token);
Headers.Insert("Content-Type", "application/x-www-form-urlencoded");
Headers.Insert("FetchShowcase", True);
HttpQuery = New HTTPRequest(URL, Headers);
HttpConnection = New HTTPConnection(ServerName, 443,,,,, New OpenSSLSecureConnection);
HttpAnswer = HttpConnection.Post(HttpQuery, "");
If HttpAnswer.StatusCode = 200 Then
BodyAnswer = HttpAnswer.GetBodyAsString(TextEncoding.UTF8);
EndIf;
|
Unfortunately, I don`t have a token, so I get this answer: "Token bulunamad". If you have any questions, I`ll be glad to answer them.
|
|
|
|
harun Fişekci
|
Oct 29, 2019 10:18 AM
|
Just came
Rating:
1
Joined: May 8, 2018
Company: Profsis Yazılım Ltd. Şti. |
Token = "bbd4c27f2fdd97710836c6c07a8d1da2"; ServerName = "http://www.atef.com.tr/rest1/console"; URL = "user/getUsers"; Headers = New Map; Headers.Insert("token", Token); Headers.Insert("Content-Type", "application/x-www-form-urlencoded"); Headers.Insert("FetchShowcase", True);
Couldn't resolve host name
Edited: harun Fişekci
- Jan 24, 2020 01:15 PM
|
|
|
|
harun Fişekci
|
Oct 29, 2019 10:26 AM
|
Just came
Rating:
1
Joined: May 8, 2018
Company: Profsis Yazılım Ltd. Şti. |
the company we work with has given examples as follows
<ht ml> <body>
<fo rm method="post" action="http://www.atef.com.tr/rest1/user/getUsers"> <input name="token" value="bbd4c27f2fdd97710836c6c07a8d1da2"/> <input name="limit" value=""/> <input name="start" value=""/> <input name="columns" value=""/> <input name="f" value=""/> <input name="orderby" value=""/> <input type="submit"> </form>
</body> </html>
|
|
|
|
harun Fişekci
|
Oct 29, 2019 10:30 AM
|
Just came
Rating:
1
Joined: May 8, 2018
Company: Profsis Yazılım Ltd. Şti. |
I am sending you sample for a coin to sample
E-commerce site: Visitor Address: http://webservice.tsoft.com.tr Administration Panel: http://webservice.tsoft.com.tr/Y Username: admin@tsoft.com.tr Password: 12345678
Web Service Application Interface (Api Console): Access Address: http://webservice.tsoft.com.tr/rest1/console Username: service Password: serv1234
|
|
|
|
Aleksandr Biryukov
|
Oct 29, 2019 11:08 AM
|
Administrator
Rating:
24
Joined: Oct 3, 2019
Company: |
Hi Harun Fişekci!
I`ll see it and write the result.
|
|
|
|
Aleksandr Biryukov
|
Nov 06, 2019 03:28 PM
|
Administrator
Rating:
24
Joined: Oct 3, 2019
Company: |
Hi Harun Fişekci!
Please send me a new token.
Just send to my mail only: abir@1c.com
|
|
|
|
harun Fişekci
|
Nov 06, 2019 04:13 PM
|
Just came
Rating:
1
Joined: May 8, 2018
Company: Profsis Yazılım Ltd. Şti. |
|
|
|
|
Aleksandr Biryukov
|
Nov 20, 2019 04:02 PM
|
Administrator
Rating:
24
Joined: Oct 3, 2019
Company: |
Hi Harun!
I understood the reason for the failure.
This code will work with your service:
Code |
---|
Procedure Command1(Command)
Token = "YourToken";
stringToken = "token=" + Token;
ServerName = "www.atef.com.tr";
URL = "/rest1/brand/getBrands";
Headers = New Map;
// Headers.Insert("token", Token); We remove this line ...
Headers.Insert("Content-Type", "application/x-www-form-urlencoded");
Headers.Insert("FetchShowcase", True);
HttpQuery = New HTTPRequest(URL, Headers);
HttpQuery.SetBodyFromString(stringToken); // ... and add this line
HttpConnection = New HTTPConnection(ServerName, 443,,,,, New OpenSSLSecureConnection);
HttpAnswer = HttpConnection.Post(HttpQuery, "");
BodyAnswer = "";
If HttpAnswer.StatusCode = 200 Then
BodyAnswer = HttpAnswer.GetBodyAsString(TextEncoding.UTF8);
EndIf;
Message(BodyAnswer);
EndProcedure
|
After these changes everything works
|
|
|
|
Aleksandr Biryukov
|
Nov 21, 2019 02:51 PM
|
Administrator
Rating:
24
Joined: Oct 3, 2019
Company: |
By the way, there is another way to work with HTTP:
Code |
---|
&AtClient
Procedure Command1(Command)
WinHttp = New COMObject("WinHttp.WinHttpRequest.5.1");
WinHttp.Open("POST", "https://www.atef.com.tr/rest1/brand/getBrands", False);
WinHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
WinHttp.Send("token=YourToken");
If WinHttp.Status = 200 Then
Message(WinHttp.ResponseText);
Else
Message("HTTP " + WinHttp.Status + " " + WinHttp.StatusText);
Return;
EndIf;
EndProcedure
|
But this method works in Windows only.
|
|
|
|
Subscribe
|