system.net.httpClient authentication issues

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

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

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

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.

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.

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

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

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

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