Michael Mc Member Licensed User Longtime User Jun 14, 2014 #1 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
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 Jun 14, 2014 #2 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
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?
Michael Mc Member Licensed User Longtime User Jun 14, 2014 #3 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
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
DonManfred Expert Licensed User Longtime User Jun 14, 2014 #4 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 HttpUtils2Service.bas 1.8 KB · Views: 635 Upvote 0
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
Michael Mc Member Licensed User Longtime User Jun 14, 2014 #5 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
Ok thanks I'll look around. Maybe someone else out here has had the same needs and will respond to this thread. Thanks again!!
Erel B4X founder Staff member Licensed User Longtime User Jun 15, 2014 #6 Change hc_ResponseSuccess to: Code: Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int) Dim job As HttpJob = TaskIdToJob.Get(TaskId) job.Tag = Response.StatusCode Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _ True, TaskId) End Sub Upvote 0
Change hc_ResponseSuccess to: Code: Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int) Dim job As HttpJob = TaskIdToJob.Get(TaskId) job.Tag = Response.StatusCode Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _ True, TaskId) End Sub
Michael Mc Member Licensed User Longtime User Jun 15, 2014 #7 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
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) .........
Erel B4X founder Staff member Licensed User Longtime User Jun 16, 2014 #8 You will need to add HttpUtils2 source code: HttpUtils2 - Web services are now even simpler Uncheck the library and add the two modules. Upvote 0
You will need to add HttpUtils2 source code: HttpUtils2 - Web services are now even simpler Uncheck the library and add the two modules.