When calling the requests.get function in the Code python node, this error happens: 'NoneType' object has no attribute 'new'. any ideas?

Describe the problem/error/question

when calling the requests.get function in the Code python node, this error happens: ‘NoneType’ object has no attribute ‘new’.

What is the error message (if any)?

‘NoneType’ object has no attribute ‘new’

Please share your workflow

I’m entering the code into the Python Code node

(I know I can try using an http node, but I have one long script I want to run in the Code node to save some time.)

Would you like to share a minimal reproducible example of this issue?

Does this help without the key and URL?

import requests
import json

headers = {
“Content-Type”: “application/json”,
“X-API-Key”: “KEY”
}

def get_data():
url = “URL”
response = requests.get(url, headers=headers)

get_data()

I get a completely different error:
RuntimeError: Blocked for security reasons
which comes from here.

is this something you had to overcome too?

Thanks, no, not sure if your error comes before mine or after. I had a few other errors to get through, but now narrowed down to this one happening on the requests.get line.

Are you running in cloud or self-hosting?

Cloud through n8n website.

I guess this is why it works (or rather doesn’t work) differently for us.
Sorry, no clouds here :slight_smile:

Thanks. I appreciate the attempt. It says Python is in beta so maybe it’s related to that.

Facing the same in a local mac installation. Literally no trace to understand what’s happening. Let me know if you find some resolution.

PS: Also using requests module

1 Like

I’m starting to think the issue is their beta version of python.

I had another issue also, with importing the data from previous nodes based on the name of the node, for example $(“GetUsersFromDatabase”), and after n8n’s AI assistant kept telling me the code would work, it finally admitted that the beta python implementation didn’t support it yet.

Not sure if that’s accurate, but I chose to believe it based on the fact that it wasn’t working, and then I tested it in javascript and it worked fine.

So my current solution is to both break up my nodes so that I use the http node instead of a python request, and I’m using more javascript and less python. So far, that’s gotten me through.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.