HttlUtils2 Error: Not Acceptable: Unknown or unsupported response format

ziomorgan

Active Member
Licensed User
Longtime User
Good morning,
I state that I have a thousand proofs and read everything I could read on the forum before posting.
I try to use a web service (working and tested with ios) which returns continually "Error: Not Acceptable: Unknown or unsupported response format."

Base code used is HttpUtils2 example:

B4X:
'Activity module
Sub Process_Globals

End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Dim job1, job2, job3 As HttpJob
   'job1.Initialize("Job1", Me)
   
   'Send a GET request
   'job1.Download2("http://www.b4x.com/print.php", _
   '   Array As String("first key", "first value :)", "second key", "value 2"))
   
   'Send a POST request
   job2.Initialize("Job2", Me)
   job2.PostString("http://www.xxxxxxxxx.com/restsrv/user/login", "username=user&password=pwd")

   'Send a GET request
   'job3.Initialize("Job3", Me)
   'job3.Download("http://www.b4x.com/forum/images/categories/android.png")
End Sub

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   If Job.Success = True Then
      Select Job.JobName
         Case "Job1", "Job2"
            'print the result to the logs
            Log(Job.GetString)
         Case "Job3"
            'show the downloaded image
            Activity.SetBackgroundImage(Job.GetBitmap)
      End Select
   Else
      Log("Error: " & Job.ErrorMessage)
      ToastMessageShow("Error: " & Job.ErrorMessage, True)
   End If
   Job.Release
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Logfile:

** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (httputils2service) Destroy **
Installing file.
PackageAdded: package:anywheresoftware.b4a.samples.httputils2
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
JobName = Job2, Success = false
Error: Not Acceptable: Unknown or unsupported response format.
** Activity (main) Pause, UserClosed = true **

Anyone can help me?

Thanks
 
Last edited:

mc73

Well-Known Member
Licensed User
Longtime User
Unless I am missing something obvious here, what I can comment is that the post string
"username=user&password=pwd" seems a bit suspicious. I suggest checking how this string is handled by your page and what it returns if the input errs.
 
Upvote 0

ziomorgan

Active Member
Licensed User
Longtime User
The service requires a user name and password to authenticate.
Responds with a cookie containing session id and session number.
But I always get the same error.
Can you help me please?

thanks
 
Last edited:
Upvote 0

ziomorgan

Active Member
Licensed User
Longtime User
I have tested the web services (made from other) with curl command line and it work fine.
Also tested with ios with same parameters and work also fine.

Can someone help me please ?
thanks
 
Upvote 0

ziomorgan

Active Member
Licensed User
Longtime User
Yes, I'm sure. The request MUST be POST.
It was also tested with the command line 'curl' and the web service responds correctly.
I can not have the server-side code because the company that produced it does not want to provide me.
Is there a way to debug calls to the server and the responses to low level?
Please do not leave me. I have to deliver the work and are also a dead end.

Thanks
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
The exception thrown has to be here:
B4X:
if (empty($response_format) || empty($mime_type)) { drupal_set_header('HTTP/1.0 406 Not Acceptable: unknown or unsupported response format.');
 exit;}
At least this is what I've found googling the error. Now, seems like server is not supporting the mime type since response_format is set to json by default. At least so I saw, but maybe I'm wrong. Just fast observations.
 
Upvote 0
Top