iOS Question httpjob error

francisco duran

Member
Licensed User
Longtime User
Hi, need your help, i am work with iHttpUtils2 but can´t send data way job.download i need send : http://192.168.4.1/$$YY%&

but the error for ever is ResponseError: unsupported URL, status code: 0

<code>
Sub Enviar_dato( env As String)
Dim job As HttpJob
Dim en As String
Dim Query As String

Query= "H"
en="http://192.168.4.1/"&env 'http://192.168.4.1/$$YY%&
job.Initialize("job_iniciar", Me)

job.Download(en)
End Sub
</code>

In Android(B4A) I also got the same error and I could solve it by including in Manifiest CreateResourceFromFile (Macro, Core.NetworkClearText)

Does anyone know how I can fix it for B4I?

Thanksss

Bye
 

roumei

Active Member
Licensed User
You probably have to encode the url, see Erel's example here: https://www.b4x.com/android/forum/threads/unsupported-url-with-imagedownloader.73147/post-464811
Make sure to check the iStringUtils library. This code works without a ResponseError but you'll have to check whether the download is what you expect. I can't test it with my router.
B4X:
Sub Enviar_dato(env As String)
    Dim j As HttpJob
    j.Initialize("", Me)
    Dim su As StringUtils
    j.Download("http://192.168.4.1/" & su.EncodeUrl(env, "utf8"))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release
End Sub

Tip: Use the 'Code' button on the top left to insert code.
Tip: If you use the forum search with the error message 'unsupported URL, status code: 0', you'll probably find the solution.
Tip: Use 'Wait For' instead of the event, it makes things much easier: https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/
 
Upvote 0

francisco duran

Member
Licensed User
Longtime User
Hi, thanks for the answers but it doesn't work for me.
I did the adjustment as I was told and the error no longer appears but there is no answer.
I am connecting from iphone to an ESP32 as an AP and I have to send it the command "http://192.168.4.1/$$YY%&".

They would have any other ideas I can try.

Thanks a lot
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Hi, thanks for the answers but it doesn't work for me.
I did the adjustment as I was told and the error no longer appears but there is no answer.
I am connecting from iphone to an ESP32 as an AP and I have to send it the command "http://192.168.4.1/$$YY%&".

They would have any other ideas I can try.

Thanks a lot
Are you creating your own webservice using language like PHP, Python or Javascript?

Have you tried to send the parameter encoded in utf8 like suggested by roumei?

Maybe you can try to test using Postman and see the results?

How is your updated code looks like now?
 
Upvote 0

roumei

Active Member
Licensed User
I'm not sure it's related but your string seems to contain an invisible (for us) character. If you hover over it in the browser it's shown as $$44%02%&. That's the encoding for 'Start of text' which seems a little bit strange. Can you show us the specification that asks you to send this string?
The utf encoding is needed because of this %02 character and the % at the end of the string. Without encoding you'll get the unsupported URL error. I don't know anything about ESPs but could it be that it doesn't expect encoded strings?
 
Last edited:
Upvote 0

francisco duran

Member
Licensed User
Longtime User
Hi, thanks for your responses. I have tried what was recommended and it does not work for me.

At the address 192.168.4.1 there is an electronic device (webserver) that has to receive that string (http://192.168.4.1/$$YY%&) to start working, from B4A it works fine, but from iphone I can't get it to it works for me.

I can't change the electronic equipment but I need to be able to start it from iphone.

If I write the string in the IOS browser the equipment works fine.

Thank you very much for your help.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Are you creating your own webservice using language like PHP, Python or Javascript?

Have you tried to send the parameter encoded in utf8 like suggested by roumei?

Maybe you can try to test using Postman and see the results?

How is your updated code looks like now?
You didn’t answer my question. Did you try to Log the value of the request?
 
Upvote 0

francisco duran

Member
Licensed User
Longtime User
Hi Aeric,
The equipment is developed in Arduino and the webservice receives that command to work, it receives it in GET mode, in POST mode it does nothing.

When I send encoded with UTF8, the command that reaches the equipment changes and it doesn't know what to do.

Postman does not return any results

Codigo:
Sub Enviar_dato( env As String)
    Dim j As HttpJob
    Dim tt,TT1 As String
    j.Initialize("", Me)
    Dim su As StringUtils

    
    j.Download("http://192.168.4.1/" & su.EncodeUrl(env, "UTF8"))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)'
    End If
    j.Release
    hd.ToastMessageShow(tt, True)
End Sub
 
Upvote 0

francisco duran

Member
Licensed User
Longtime User
Code:
#Region  Project Attributes
    #ApplicationLabel: OzonoCleaner T20
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone
    #ATSEnabled: false
    #MinVersion: 8
    #Entitlement: <key>com.apple.developer.networking.wifi-info</key><true/>
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><false/>
#PlistExtra: <key>NSExceptionDomains</key><dict>
'list the excluded domains (example.com and b4x.com)
#PlistExtra: <key>192.168.4.1</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>
'end of excluded domains
#PlistExtra: </dict>
#PlistExtra: </dict>
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/>
#PlistExtra: <key>NSAllowsArbitraryLoadsInWebContent</key><true/>
#PlistExtra: </dict>
#End Region
 
Upvote 0
Top