Android Question Get the HttpResponse Code

Michael Mc

Member
Licensed User
Longtime User
I'm using httputils2 with a REST Web Service (Web Api actually). I need to get the response codes after the job completes.

Our Rest Service used Response Status Codes like:
200 - ok
201 - Created
202 - Accepted
etc.

I don't see them anywhere or I'm missing it.
Thanks
 

DonManfred

Expert
Licensed User
Longtime User
How does your Rest Service "Response" this? Useually a Rest Service will Response a JSON or XML. And the "Status" is Part of this json or XML.
What will the Rest return if you call the rest from a webbrowser?
 
Upvote 0

Michael Mc

Member
Licensed User
Longtime User
The response code is not part of any response contents (Json or xml). It belongs to the header of all http client server requests.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6

I think that httputils2 is made so simple that it is only checking for response code 200 and then setting
Job.Success as true anything else it sets Job.Success to false. I would assume.

I thought maybe it would have some strange properties after you made the initial request like (GetRequest):


scanjob.Download( Main.webserver & "/api/item/GetItemExtended/" & TBUPCSKU.text.Replace(" ","%20"))
scanjob.GetRequest.SetHeader("Authorization","Basic " & Functions.GetUserPassword)

Any idea how to get the standard response header or do I need to find something else besides httputils2 lib to get the job done.

Thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Maybe this one helps? It´s a httputils2 Service code i found somewhere here in forum.
In sub hc_ResponseError you probably get the StatusCode

But i dont know how to combine this StatusCode with the "right httpJob" in JobDone
 

Attachments

  • HttpUtils2Service.bas
    1.8 KB · Views: 228
Upvote 0

Michael Mc

Member
Licensed User
Longtime User
Ok thanks I'll look around.

Maybe someone else out here has had the same needs and will respond to this thread.

Thanks again!!
 
Upvote 0

Michael Mc

Member
Licensed User
Longtime User
Thanks Erel,

But I'm really not sure where this is to go. I'm using httputils2 with


Dim scanjob As HttpJob
ProgressDialogShow2("Gathering Data",True)
scanjob.Initialize("scanjob",Me)
Scanjob.Download( Main.webserver & "/api/item/GetItemExtended/" & TBUPCSKU.text.Replace(" ","%20"))
scanjob.GetRequest.SetHeader("Authorization","Basic " & Functions.GetUserPassword)
........

Sub JobDone(Job As HttpJob)
StatusPanel.Visible=True
ProgressDialogHide
If Job.Success Then
Functions.ToneGood
Select Job.JobName
Case "scanjob"
UpdateScreen(Job.GetString,0)

.........
 
Upvote 0
Top