Page 1 of 1

Simple GET request to a URL.

Posted: Thu Sep 22, 2016 10:45 am
by jfox21381
I'm working on a project where I need to validate a barcode number, read by a barcode scanner. My client has provided me with an API to validate the scanned number. The information provided to me is as follows:
There is a barcode verification API, that I'd prefer you use, you simply do a GET to a URL with the barcode value in the URL. This will return a 404 if invalid and a 200 (with a JSON body) if it is valid.
I have the URL I need and I don't care about the JSON return, I just need to get the 404 or 200 response. Are there any samples out there on how to accomplish this?

Re: Simple GET request to a URL.

Posted: Thu Sep 22, 2016 2:22 pm
by pbreed
Look at the webclient examples....

The simplest is probably the

nburn\examples\standardstack\webclient\FindMyIp


uses a very similar API....
One line get with a result check...


Paul

Re: Simple GET request to a URL.

Posted: Fri Sep 23, 2016 6:57 am
by jfox21381
Hi Paul,

Thanks! This looks very close to what I need. I got the sample working properly on my device, but when I plug in my clients URL, the DoGet always returns false. I can see the return data when using the URL in a browser.

This is the test url: https://[removed since it's no longer needed]

Is there any way to just get the 404 or 200 results values?

Re: Simple GET request to a URL.

Posted: Fri Sep 23, 2016 10:41 am
by pbreed
that request is HTTPS ie it uses TLS/SLL.
The other is HTTP....

Your site does not seem to respond to http requests....

So you need to get the site to allow http, or you need to purchase add SSL/TLS libraries for Netburner...

Paul

Re: Simple GET request to a URL.

Posted: Fri Sep 23, 2016 10:43 am
by pbreed
When you sent the http request the
website responds with 301 moved permanently and provides the https address as the location it moved to.


Paul

Re: Simple GET request to a URL.

Posted: Fri Sep 23, 2016 10:55 am
by jfox21381
Ok, that makes sense. I'll ask the client if that can allow the HTTP. Thanks again for your help!