[BUG? ]Code in Webdev python resource won't execute (redirect_policy in system.net.httpClient DOES NOT defaults to "NORMAL")

I’m trying to get simple httpGet and httpPost to get working, but …
I have this simple python resource in Webdev module called readTags.
And in Script console this code:


The code in the Webdev module never gets executed.
I was spending last 8 hours going through every forum post about webdev and httpPost and Get and I can’t figure it out…

Your web dev script is not returning anything. Read the top part, you need to return a dictionary with the appropriate key and response to the request.

Also your logger will log to the gateway logs if you are trying to look for errors or loggers you need to be on the gateway.

Yes, I know that my Webdev script is not returning anything.
The problem is that it doesn’t get executed at all.
It won’t print in wrapper.log and in gateway logs and also there are no ‘myLogger’ entries…

I managed to get httpPost working… but client.post or client.get or client.put is still not…
I’m really confused…

How are you testing it?

Sorry just saw.

Can you test with postman and see if that makes a difference?

Finally, it’s working.
I had to put redirect_policy = "NORMAL" into the

client = system.net.httpClient(redirect_policy = "NORMAL")


If the manual were OK, then I wouldn’t spend two days on this…

1 Like

You do not need the /main in the url. That changed in ignition 8. That’s why your getting a http 307 redirect response code.

Vau! :roll_eyes:
How the f**k should I know that?

1 Like

The URLs in the WebDev docs are all accurate and do not include /main in the URL. I guess if you started in 7.9 and then upgraded this corner case might get you.

1 Like

That must be it.
Regardless, my point about redirect_policy still stands:
If you have /home in your URL, and create system.net.httpClient() without redirect_policy="NORMAL" then it won't work.
So, it doesn't default to "NORMAL"... ?

The default redirect policy for Java 11’s HttpClient is never, which is the safest default policy.

The reason I call this a corner case is aside from the removal of /main and the redirect that replaced it, most WebDev endpoints aren’t even consumed by Ignition’s own HTTP client, but rather they are consumed by external entities.

edit: Oh I see, our docs say it defaults to “normal” though… Do you have HTTPS enabled? “Normal” means “follow redirects unless it’s an HTTPS → HTTP redirect”… maybe that has something to do with it.

edit2: I think our docs are just wrong. Sorry that caused you some grief.

1 Like