Android Question CURL syntax with Basic Auth

Discussion in 'Android Questions' started by Daniel-White, Jul 2, 2015.

  1. Daniel-White

    Daniel-White Active Member Licensed User

    Hi guys, I am exploring how will be the syntax of this curl to something like httputils2 ,httpjob or similar B4A.

    curl -X DELETE --user username : password http://exampleweb.test.com/posts/1

    I have problem about how tell to the web using B4A , the "DELETE" and how give to the website the username and password.

    the http://exampleweb.test.com/posts/1 is a json

    the auth is basic that mean base 64 encode.

    Thanks you Indeed.
    Daniel W
     
    Last edited: Jul 2, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Use HttpUtils2 source code instead of the library and add this sub to HttpJob:
    Code:
    Public Sub Delete(Link As String)
       req.InitializeDelete(Link)
       CallSubDelayed2(HttpUtils2Service, 
    "SubmitJob", Me)
    End Sub
     
  3. Daniel-White

    Daniel-White Active Member Licensed User

    Thanks you Indeed Erel, one question for everybody here, when use the credentials in httputils2 "To send credentials you should set Job.UserName and Job.Password fields before sending the request." I read from http://www.b4x.com/android/forum/threads/httputils2-web-services-are-now-even-simpler.18992/#content it will need to encode with base64? or it is done?, I use my sniffer when run curl, and see the credentials example username : password like this example daniel:123 in plain text and the encoding in 64 is like this ZGFuaWVsOjEyMw==

    I am trying to do the same with B4A , I did with curl, the web is wordexpress. and I am little bit confuse with username : password and base64, it will be a header? how format that in B4A. I read a similar code here http://www.b4x.com/android/forum/threads/i-need-help-with-pushbullet-api.38520/#post-228254, but I did not see the base 64 for basic auth.
    Thanks
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Basic authentication doesn't require the password to be base 64 encoded. You can use StringUtils to encode it.
     
Loading...