Hello,
This is the info i get from the manufacturar:
I tried this:
I also tried to make a JSON string and send it with POST string.
I always get as result SUCCES.
When i read the device i see this:
Strange characters instead of //
What am i doing wrong??
This is the info i get from the manufacturar:
Set Config
curl -v -d "single=<url>&double=<url>&long=<url>&touch=<url>" http://[IP]/api/v1/device/[MAC]
The order of parameters is not relevant. Request must have at least one parameter. URL to be sent must be encoded using x-www-form-urlencoded notation.
In order to make it possible and simple at the same time to specify in the URL that specific request should be sent as GET or POST we introduced a special (very unusual) conventions. URL is considered as get when it starts with get:// and as post when it starts with post:// (in both cases get and post replaces the usual http prefix). GET is sent as is and POST is sent such, that parameters from URL are sent as POST body.
I tried this:
B4X:
Dim S1 As String = ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim S2 As String = ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim S3 As String = ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim S4 As String = ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim NV As Map
NV.Initialize
NV.Put("single", S1)
NV.Put("double", S2)
NV.Put("long", S3)
NV.Put("touch", S4)
Dim req As OkHttpRequest
req = MultipartPost.CreatePostRequest("http://192.168.254.1/api/v1/device/"&ButtonMac, NV, Null)
req.SetHeader("Content-Type", "application/json")
req.SetContentType("application/json")
req.SetContentEncoding("text/plain")
hc.Execute(req, 1)
I also tried to make a JSON string and send it with POST string.
B4X:
Dim S1 As String = "single="&ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim S2 As String = "double="&ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim S3 As String = "long="&ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim S4 As String = "touch="&ServerIP&":61042/MyStrom?id="&ButtonID&"&fi="&FleetID&"&tp=1&msg="&MessageTxt&"&ads="&MessageAdress
Dim X As Map
X.Initialize
X.Put("single",S1)
X.Put("double",S2)
X.Put("long",S3)
X.Put("touch",S4)
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(X)
Dim R As String = JSONGenerator.ToPrettyString(2)
Dim J As HttpJob
J.Initialize("AST1",Me)
j.PostString("http://192.168.254.1/api/v1/device/"&ButtonMac,R)
j.GetRequest.SetContentType("application/x-www-form-urlencoded")
I always get as result SUCCES.
When i read the device i see this:
Strange characters instead of //
B4X:
response: anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpResponse@78dc88f
BSSID 62:01:94:27:ec:bd
{
"single": "http:\/\/85.214.204.131:61042\/MyStrom?id",
"double": "",
"long": "",
"touch": "",
"generic": ""
}
What am i doing wrong??