# HTTP Get Function Help

**URL:** <https://forum.inductiveautomation.com/t/http-get-function-help/36363>\
**Category:** Maker\
**Created:** [July 5, 2020, 12:17am UTC](https://forum.inductiveautomation.com/t/http-get-function-help/36363 "2020-07-05T00:17:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kuskah](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kuskah](https://forum.inductiveautomation.com/u/Kuskah)\
**Post date:** [July 5, 2020, 12:17am UTC](https://forum.inductiveautomation.com/t/http-get-function-help/36363/1 "2020-07-05T00:17:12Z")

</div>

So I am trying to use the system.net.httpGet function to return the saftware version of my IP camera(s). I keep getting a 401 error response and am uncertain as to why.

```auto
url = "http://IPAddressofCamera/cgi-bin/magicBox.cgi?action=getSoftwareVersion"
user = 'username'
passwd = 'password'

vers = system.net.httpGet(url, username=user, password=passwd)
print vers

```

And the response looks like:

```auto
Traceback (most recent call last):
  File "<input>", line 5, in <module>
IOError: Server returned HTTP response code: 401 for URL: http://IPAddressofCamera/cgi-bin/magicBox.cgi?action=getSoftwareVersion

```

When I enter the same address into chrome, it asks for username and password, to which I enter the same user and password as the code. Once this is completed, it displays a webpage with the information I would expect.

Does anyone have any idea as to what could be the problem here?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 5, 2020, 2:13am UTC](https://forum.inductiveautomation.com/t/http-get-function-help/36363/2 "2020-07-05T02:13:05Z")

</div>

> [@Kuskah](#):
>
> system.net.httpGet

This function is deprecated for a variety of reasons, including authentication problems. Use system.net.httpClient instead.

---

<div class="post-metadata">

**Author:** ![Kuskah](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@Kuskah](https://forum.inductiveautomation.com/u/Kuskah)\
**Post date:** [July 5, 2020, 11:07am UTC](https://forum.inductiveautomation.com/t/http-get-function-help/36363/3 "2020-07-05T11:07:03Z")

</div>

Thank for the response Phil. However I am still getting the same error.

I have tried the system.net.httpClient a couple different ways, all with the same response.

I started with the following:

```auto
url = "http://IPAddress/cgi-bin/magicBox.cgi?action=getSoftwareVersion"
user = 'username'
passwd = 'password'

client = system.net.httpClient(username=user, password=passwd, bypass_cert_validation = True,cookie_policy = "ACCEPT_ALL",redirect_policy="ALWAYS")
vers = client.get(url)

print vers

```

and I get a response of:

```auto
>>> 
<Response@1882423925 'http://IPAddress/cgi-bin/magicBox.cgi?action=getSoftwareVersion' [401]>
>>> 

```

So I then tried putting the user and password as part of the client.get and still get the same response.

```auto
url = "http://IPAddress/cgi-bin/magicBox.cgi?action=getSoftwareVersion"
user = 'username'
passwd = 'password'

client = system.net.httpClient(bypass_cert_validation = True,cookie_policy = "ACCEPT_ALL",redirect_policy="ALWAYS")
vers = client.get(url, username=user, password=passwd)

```

So obviously I am doing something wrong and am uncertain of what it is. Does anyone have any insights?

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [July 6, 2020, 5:56am UTC](https://forum.inductiveautomation.com/t/http-get-function-help/36363/4 "2020-07-06T05:56:09Z")

</div>

My guess would be that the camera doesn’t take HTTP Basic Auth, which is what httpClient is passing in.

Error 401 is an unauthorized error.

You could certainly print out the text of the response as well. It _might_ give you a little more info:

print vers.getText()  
(For other functions available for the Response object, see the docs in [https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient](https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient) )

Since this is less a post about Ignition and more a post about REST communication, my recommendation would be to use a free tool like PostMan ( [https://www.postman.com/](https://www.postman.com/) ) to make sure you get your REST calls right. It has a nice interface that lets you test communication intended exactly for working out this type of request. After you have that working, then you can throw the right settings and options into Ignition’s httpClient() call.

In your requests you might end up needing to set some cookies, pass in authentication using something other than HTTP Basic Auth (using a post possibly with form data, and getting back a token, for example). If you want to watch how the browser does it, you can open up Chrome’s Dev Tools ( Ctrl-Shift-I ) and watch the Network tab. It has details on the headers and data in the requests and responses.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![joey.philippi](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@joey.philippi](https://forum.inductiveautomation.com/u/joey.philippi)\
**Post date:** [February 1, 2021, 1:57pm UTC](https://forum.inductiveautomation.com/t/http-get-function-help/36363/5 "2021-02-01T13:57:54Z")

</div>

@Kuskah, were you able to solve your issue? I’m running into the same problem with my cameras due to an unsecure http secondary message. Any insight into your solution would be greatly appreciated. Thanks
