# system.net.httpClient authentication issues

**URL:** <https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [May 8, 2025, 4:32pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063 "2025-05-08T16:32:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Ford-King](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_Ford-King](https://forum.inductiveautomation.com/u/Alex_Ford-King)\
**Post date:** [May 8, 2025, 4:32pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/1 "2025-05-08T16:32:20Z")

</div>

I am trying to call a patch API to our maintenance software, Limble. I keep getting back a invalid credentials error. There API requires basic base 64 encoding. If anyone has any ideas it wold be very helpful! Thanks

```python
from java.util import Base64

# Create an HTTP client
client = system.net.httpClient()

# Define the URL and the payload
url = "https://api.limblecmms.com/v2/assets/fields/1416/"
payload = {"value": 5000}

# Encode your username and password for Basic Authentication
username = "ClientID"
password = "ClientSecret"
credentials = "{username}:{password}"
encoded_credentials = base64.b64encode(credentials.encode()).decode()

# Define headers for Basic Authentication
headers = {
    "Content-Type": "application/json",
    "Authorization": "Basic" + encoded_credentials
}

# Make the PATCH request
response = client.patch(url, data=payload, headers=headers)

# Check the response
if response.statusCode == 200:
    print("Field updated successfully!")
else:
    print("Failed to update field. Status code: {response.status_code}")
    print(response.text)
print encoded_credentials

```

EDIT: For any one later with a similar issue. Passing the user and password in the header is the wrong. Like Kevin said, its better to pass them through the client.Patch

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 8, 2025, 4:38pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/2 "2025-05-08T16:38:32Z")

</div>

`system.net.httpClient` knows how to do basic auth. Just give it the username and password when you create it.

> **[system.net.httpClient | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-net/system-net-httpClient#parameters)**
>
> Provides a general use object that can be used to send and receive HTTP requests.

---

<div class="post-metadata">

**Author:** ![Alex\_Ford-King](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_Ford-King](https://forum.inductiveautomation.com/u/Alex_Ford-King)\
**Post date:** [May 8, 2025, 4:52pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/3 "2025-05-08T16:52:35Z")

</div>

I have tried that as well but still get the same error. I am able to run the call in postman so i know it is the correct username and password. I don't know if I'm using the correct syntax though.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 8, 2025, 4:59pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/4 "2025-05-08T16:59:08Z")

</div>

well there's no syntax to worry about when you let the client do it. Make sure you're not trying to add your own headers when you configure the client with the username/password.

> [@Alex\_Ford-King](#):
>
> `"Authorization": "Basic" + encoded_credentials`

This is probably missing a space between "Basic" and the encoded credentials.

---

<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:** [May 8, 2025, 5:09pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/5 "2025-05-08T17:09:58Z")

</div>

And this isn't doing what you think, either:

> [@Alex\_Ford-King](#):
>
> `credentials = "{username}:{password}"`

That's just a string constant. No substitution magically happens there.

---

<div class="post-metadata">

**Author:** ![Alex\_Ford-King](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_Ford-King](https://forum.inductiveautomation.com/u/Alex_Ford-King)\
**Post date:** [May 8, 2025, 5:32pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/6 "2025-05-08T17:32:21Z")

</div>

I was passing the user and password from the header but using the client was the solution. Thanks for the help

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [October 15, 2026, 7:26pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-authentication-issues/106063/7 "2026-10-15T19:26:29Z")

</div>

I know this is old but do you have an example of how you got it working?
