Android Question HTTP Response Status Code

Discussion in 'Android Questions' started by Derek Jee, Jun 27, 2015.

  1. Derek Jee

    Derek Jee Active Member Licensed User

    Hello there

    I am writing an app which talks to a web api written in VB and it receives data back. In some instances I want to return a different status code based on what I am looking for in a database. For instance I query my database for some data to download and see that it is no longer there and want to send a 410 gone.. In Vb I can send

    response.StatusCode = 410
             response.StatusDescription = 
    Which does send the message back to the app but it is not reflected in the job.tag (StatusCode in HTTPJob module) but just sends a HTML 410 page and an error in B4A. I really want the job.tag to tell me this status..

    I hope this makes sense, if so can anyone advise..

    Thank you,

  2. Erel

    Erel Administrator Staff Member Licensed User

    Use HttpUtils2 source code instead of the library and add these two lines to hc_ResponseSuccess:
    Dim job As HttpJob = TaskIdToJob.Get(TaskId)
       job.Tag = Response.StatusCode
    Derek Jee likes this.
  3. Derek Jee

    Derek Jee Active Member Licensed User

    Thank you Erel..

    I saw another response with the same advice and put it in place. Works a treat. Thank you :)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice