Android Question [SOLVED] Send LINE Notifity With B4A

Jones Hone

Active Member
Licensed User
Longtime User
There is an error message in my program, how can I solve it.
B4X:
'Reference: HTTP & HttpUtils2 Library
Dim http As HttpJob
Dim url As String
url = "https://notify-api.line.me/api/notify"
http.Initialize("",Me)
http.GetRequest.SetHeader("Authorization", "Bearer ZOWe17zgDOzPCwcgBvugMg4ADFeLKenIj7zmJP9MTYs")
http.GetRequest.SetContentType("application/x-www-form-urlencoded")
http.PostString(url,"message=Hollo!")
The following error message occurred: The error position is in the sixth column.
 

eps

Expert
Licensed User
Longtime User
The Authorization part of the Header you are setting looks odd to me... Is this as per the documentation for that endpoint?
 
Upvote 0

Jones Hone

Active Member
Licensed User
Longtime User
@DonManfred:
I has switch to okhttputils2. However, there are still errors.
@eps:
Yes, The Authorization part is as per the documentation for that endpoint.

This code was successfully executed in VB6, I want to port it to B4A.
 
Upvote 0

Jones Hone

Active Member
Licensed User
Longtime User
Maybe ask another way.
How to transfer the following vb6 code to b4a. Thank you.
VB6 Code:
Dim HttpClient As Object,url As String
Set HttpClient = CreateObject("MSXML2.ServerXMLHTTP")
mKEY = "ZOWe17zgDOzPCwcgBvugMg4ADFeLKenIj7zmJP9MTYs"
msg = "message=" & vbCrLf & "This is test message."
url = "https://notify-api.line.me/api/notify"
HttpClient.Open "POST", url, False
HttpClient.SetRequestHeader "Authorization", "Bearer " & mKEY
HttpClient.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HttpClient.Send msg
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You need to call Job.PostString before making the changes to the request object.

 
Upvote 0

Jones Hone

Active Member
Licensed User
Longtime User
Oh, that's it! Just move ".PostString" to the front and it's ok.
Erel, Thank you very much.
B4X:
Dim http As HttpJob
Dim url As String
url = "https://notify-api.line.me/api/notify"
http.Initialize("",Me)
http.PostString(url,"message=Hollo!")
http.GetRequest.SetHeader("Authorization", "Bearer ZOWe17zgDOzPCwcgBvugMg4ADFeLKenIj7zmJP9MTYs")
http.GetRequest.SetContentType("application/x-www-form-urlencoded")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…