# system.net.httpGet error

**URL:** <https://forum.inductiveautomation.com/t/system-net-httpget-error/38937>\
**Category:** Maker\
**Tags:** scripting\
**Created:** [September 22, 2020, 1:59pm UTC](https://forum.inductiveautomation.com/t/system-net-httpget-error/38937 "2020-09-22T13:59:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamerplc](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@tamerplc](https://forum.inductiveautomation.com/u/tamerplc)\
**Post date:** [September 22, 2020, 1:59pm UTC](https://forum.inductiveautomation.com/t/system-net-httpget-error/38937/1 "2020-09-22T13:59:05Z")

</div>

Hi,  
I am trying to run some GET API requests. but it gave me errors `IOError: Server returned HTTP response code: 401 for URL: [https://api2.kaiza.la//v1/accessToken](https://api2.kaiza.la//v1/accessToken) which related to authentication.  
The original code run well in POSTMAN tools but when I converted the code to be matched with ignition it’s not working

PostMan code:

```auto
import requests

url = "https://api2.kaiza.la//v1/accessToken"

payload = {}
headers = {
  'applicationId': 'f8cd93db-8e94-4c4@2',
  'applicationSecret': '7T3OY',
  'refreshToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ld5SH_Xgyq2C4fyKgGLKcal7RYzgY20VG6Y3t2mIZtU'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))

```

My Code in ignition

```auto
import system

url = "https://api2.kaiza.la//v1/accessToken"

payload = {}
headers = {
  'applicationId': 'f8cd93db-8e94-4c4@2',
  'applicationSecret': '7T3OY',
  'refreshToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ld5SH_Xgyq2C4fyKgGLKcal7RYzgY20VG6Y3t2mIZtU'
     }
response = system.net.httpGet(url,headers=headers, data = payload)
print response
print(response.text.encode('utf8'))

```

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [September 22, 2020, 2:17pm UTC](https://forum.inductiveautomation.com/t/system-net-httpget-error/38937/2 "2020-09-22T14:17:33Z")

</div>

I don’t know if it will solve the problem, but look into using [system.net.httpClient](https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient) if you’re at 8.0.6 or later. @paul-griffith has articulated the benefits in various places throughout the forum.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 22, 2020, 3:21pm UTC](https://forum.inductiveautomation.com/t/system-net-httpget-error/38937/3 "2020-09-22T15:21:31Z")

</div>

I’ll second @zacht’s recommendation, but, even outside of that:  
Are you sure you’ve got the structure of those headers correct? _Most_ REST/web APIs use the standard `Authentication` header, with a structure like `Authentication: Bearer ${token}` or `Authentication: token ${token}` - while it’s certainly possible the service is using a non-standard header like `refreshToken`, it seems more likely that it’s either expecting that as a URL parameter, _or_ embedded inside an `Authentication` header.

---

<div class="post-metadata">

**Author:** ![tamerplc](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@tamerplc](https://forum.inductiveautomation.com/u/tamerplc)\
**Post date:** [September 23, 2020, 9:58am UTC](https://forum.inductiveautomation.com/t/system-net-httpget-error/38937/4 "2020-09-23T09:58:34Z")

</div>

Thanks @zacht & @paul-griffith  
it’s work fine 🙏with `system.net.httpClient()`
