1. Post the relevant code. Best is to upload a small project showing the issue
2. Post ERRORS as TEXT as it is text.
The documentation is here. Your request is incomplete
Hi Don,
Thank you for your reply, I appreciate the help from you experts.
You say my request is incomplete, please explain what I have left out?
-----------------------------------------------------------------
My B4A code is really simple, this is what I have so far:
Dim ServerURL As String = "https://api.bulksms.com/v1/messages"
Dim j As HttpJob
j.Initialize("", Me)
j.Username="xxxxxx"
j.Password="xxxxxx"
Dim msg As String = "{""to"": ""+27745428191"",""body"": ""Hello World""}"
j.PostString(ServerURL, msg)
j.GetRequest.SetContentType("application/json")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
-----------------------------------------------------------------------
This is my 100% working and tested VB.Net code (from my website which I am trying to replicate in B4A):
Dim myData as String
Dim strCellPhoneNo as String = "+277235428191"
Dim strMessage as string = "Hello World"
myData = "{""to"": """ & strCellPhoneNo & """, ""body"":""" & strMessage & """}"
Dim myURI As String = "https://api.bulksms.com/v1/messages" '
Dim request = WebRequest.Create(myURI)
'Put in Account Credentials.
Dim myUsername As String = "xxxx"
Dim myPassword As String = "xxxx"
request.Credentials = New NetworkCredential(myUsername, myPassword)
request.PreAuthenticate = True
request.Method = "POST"
request.ContentType = "application/json"
Dim encoding = New UnicodeEncoding()
Dim encodedData = encoding.GetBytes(myData)
'Send the data to the Server.
Dim stream = request.GetRequestStream()
stream.Write(encodedData, 0, encodedData.Length)
stream.Close()
'Get a response from the Server.
Dim response = request.GetResponse()
'Put the response in a Reader object.
Dim reader = New StreamReader(response.GetResponseStream())
Now the error is get on the B4A code is this: 'Unable to create service co.za.Falconsoft.Golfanywhere.httputils2service: java.lang.RuntimeException: '
But I don't know what the problem is?
I have added the OkHttp & OkHttpUtils2 libraries as references to the project.
Any other help, would be greatly appreciated.
Here is the error:
Logger connected to: Xiaomi Redmi Note 7
--------- beginning of system
--------- beginning of crash
--------- beginning of main
*** Service (httputils2service) Create ***
** Activity (main) Pause, UserClosed = false **
java.lang.RuntimeException: Unable to create service co.za.Falconsoft.Golfanywhere.httputils2service: java.lang.RuntimeException: anywheresoftware.b4a.B4AUncaughtException
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3577)
at android.app.ActivityThread.access$1400(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.RuntimeException: anywheresoftware.b4a.B4AUncaughtException
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at co.za.Falconsoft.Golfanywhere.httputils2service.onCreate(httputils2service.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3565)
... 8 more
Caused by: anywheresoftware.b4a.B4AUncaughtException
at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:210)
at anywheresoftware.b4a.debug.Debug.wait(Debug.java:217)
at anywheresoftware.b4a.shell.Shell.debugPause(Shell.java:544)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:417)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
... 11 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
If you need anything else, please let me know.
Thank you again for your valuable time.
Regards,
Jacques.